mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-26 07:13:24 +03:00
Merge pull request #899 from imajes/develop
[CHORE] Fix the vimr script to support python3
This commit is contained in:
commit
1fc62dff78
@ -1,13 +1,12 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import urllib
|
import urllib.parse
|
||||||
import subprocess
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
class Action:
|
class Action:
|
||||||
ACTIVATE = "activate"
|
ACTIVATE = "activate"
|
||||||
OPEN = "open"
|
OPEN = "open"
|
||||||
@ -37,7 +36,7 @@ def call_open(action, query_params, args):
|
|||||||
if args.wait:
|
if args.wait:
|
||||||
query_params[QueryParamKey.WAIT] = "true"
|
query_params[QueryParamKey.WAIT] = "true"
|
||||||
|
|
||||||
url = "vimr://{0}?{1}".format(action, urllib.urlencode(query_params, True).replace('+', '%20'))
|
url = "vimr://{0}?{1}".format(action, urllib.parse.urlencode(query_params, True))
|
||||||
|
|
||||||
if args.dry_run:
|
if args.dry_run:
|
||||||
print("/usr/bin/open {0}".format(url))
|
print("/usr/bin/open {0}".format(url))
|
||||||
@ -79,7 +78,7 @@ def main(args):
|
|||||||
os.remove(pipe_path)
|
os.remove(pipe_path)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.mkfifo(pipe_path, 0600)
|
os.mkfifo(pipe_path, 0o600)
|
||||||
except OSError as error:
|
except OSError as error:
|
||||||
print("ERROR: {0}\n"
|
print("ERROR: {0}\n"
|
||||||
"{1} could not be mkfifo'ed.\n"
|
"{1} could not be mkfifo'ed.\n"
|
||||||
@ -97,7 +96,7 @@ def main(args):
|
|||||||
env_file = "/tmp/com_qvacua_vimr_env_{0}".format(uuid_str)
|
env_file = "/tmp/com_qvacua_vimr_env_{0}".format(uuid_str)
|
||||||
with open(env_file, "w") as f:
|
with open(env_file, "w") as f:
|
||||||
f.write(json.dumps({k: v for (k, v) in os.environ.items()}))
|
f.write(json.dumps({k: v for (k, v) in os.environ.items()}))
|
||||||
os.chmod(env_file, 0600)
|
os.chmod(env_file, 0o600)
|
||||||
query_params[QueryParamKey.ENV_PATH] = env_file
|
query_params[QueryParamKey.ENV_PATH] = env_file
|
||||||
|
|
||||||
if args.nvim:
|
if args.nvim:
|
||||||
|
Loading…
Reference in New Issue
Block a user