1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-24 14:23:34 +03:00

[CHORE] Fix the vimr script to support python3

This commit is contained in:
James Cox 2022-02-03 16:51:06 -06:00
parent 751237cc8f
commit 0994c59fa2
No known key found for this signature in database
GPG Key ID: D80F4598CB239FD6

View File

@ -1,13 +1,12 @@
#!/usr/bin/python
#!/usr/bin/env python3
import urllib
import urllib.parse
import subprocess
import argparse
import os
import uuid
import json
class Action:
ACTIVATE = "activate"
OPEN = "open"
@ -37,7 +36,7 @@ def call_open(action, query_params, args):
if args.wait:
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:
print("/usr/bin/open {0}".format(url))
@ -79,7 +78,7 @@ def main(args):
os.remove(pipe_path)
try:
os.mkfifo(pipe_path, 0600)
os.mkfifo(pipe_path, 0o600)
except OSError as error:
print("ERROR: {0}\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)
with open(env_file, "w") as f:
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
if args.nvim: