Files
copyparty/.vscode/launch.py

46 lines
978 B
Python
Raw Normal View History

# takes arguments from launch.json
# is used by no_dbg in tasks.json
# launches 10x faster than mspython debugpy
# and is stoppable with ^C
2021-06-08 20:18:24 +02:00
import re
import os
import sys
2021-06-11 18:12:06 +02:00
print(sys.executable)
2021-04-16 21:23:53 +02:00
import shlex
import jstyleson
2021-06-08 20:18:24 +02:00
import subprocess as sp
2021-06-11 18:12:06 +02:00
2021-05-13 22:58:36 +02:00
with open(".vscode/launch.json", "r", encoding="utf-8") as f:
tj = f.read()
oj = jstyleson.loads(tj)
argv = oj["configurations"][0]["args"]
2021-04-16 21:23:53 +02:00
try:
sargv = " ".join([shlex.quote(x) for x in argv])
print(sys.executable + " -m copyparty " + sargv + "\n")
except:
pass
2021-04-11 17:36:38 +02:00
argv = [os.path.expanduser(x) if x.startswith("~") else x for x in argv]
2021-06-08 20:18:24 +02:00
if re.search(" -j ?[0-9]", " ".join(argv)):
argv = [sys.executable, "-m", "copyparty"] + argv
sp.check_call(argv)
else:
sys.path.insert(0, os.getcwd())
from copyparty.__main__ import main as copyparty
try:
copyparty(["a"] + argv)
except SystemExit as ex:
if ex.code:
raise
print("\n\033[32mokke\033[0m")
sys.exit(1)