From 5e159432afc273d1a46b6f766f6b6d3a91e51e80 Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 8 Jun 2021 20:18:24 +0200 Subject: [PATCH] vscode: support running with -jN --- .vscode/launch.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.vscode/launch.py b/.vscode/launch.py index 809fa2a2..99d6a90e 100644 --- a/.vscode/launch.py +++ b/.vscode/launch.py @@ -3,14 +3,12 @@ # launches 10x faster than mspython debugpy # and is stoppable with ^C +import re import os import sys import shlex - -sys.path.insert(0, os.getcwd()) - import jstyleson -from copyparty.__main__ import main as copyparty +import subprocess as sp with open(".vscode/launch.json", "r", encoding="utf-8") as f: tj = f.read() @@ -25,11 +23,19 @@ except: pass argv = [os.path.expanduser(x) if x.startswith("~") else x for x in argv] -try: - copyparty(["a"] + argv) -except SystemExit as ex: - if ex.code: - raise + +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)