From 73aa9552dc4d7849f4d395ef9c24e6ca1777082f Mon Sep 17 00:00:00 2001 From: joknarf Date: Mon, 24 Jun 2024 12:55:51 +0200 Subject: [PATCH] windows support --- pyproject.toml | 6 +++++- ssh_para/ssh_para.py | 16 +++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6a3ee90..2f021c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,11 @@ maintainers = [ ] description = "Interactive Parallel SSH jobs manager" -dependencies = ["colorama","dataclasses>=0.6; python_version < '3.7'"] +dependencies = [ + "colorama", + "dataclasses>=0.6; python_version < '3.7'", + "windows-curses>=2.3.3; platform_system == 'Windows'", +] dynamic=["version"] readme = "README.md" license = {file = "LICENSE"} diff --git a/ssh_para/ssh_para.py b/ssh_para/ssh_para.py index 0aa78dd..64fdeff 100644 --- a/ssh_para/ssh_para.py +++ b/ssh_para/ssh_para.py @@ -201,8 +201,11 @@ def __init__(self, command, nbthreads, nbjobs, dirlog): self.startsec = time() self.stdscr = None self.paused = False - home = os.environ["HOME"] - self.pdirlog = sub(f"^{home}/", "~/", self.dirlog) + home = os.environ.get("HOME") + if home: + self.pdirlog = sub(rf"^{home}/", "~/", self.dirlog) + else: + self.pdirlog = self.dirlog if sys.stdout.isatty(): self.init_curses() super().__init__() @@ -547,12 +550,15 @@ def main(): if args.job: dirlog += f"/{args.job}" dirlog += "/" + str(int(time())) + if not os.path.isdir(dirlog): + os.makedirs(dirlog) latest = f"{args.dirlog}/latest" if os.path.exists(latest): os.unlink(latest) - os.symlink(dirlog, latest) - if not os.path.isdir(dirlog): - os.makedirs(dirlog) + try: + os.symlink(dirlog, latest) + except OSError: + pass hosts = [] with open(args.hostsfile, "r", encoding="UTF-8") as fhosts: for i in fhosts.readlines():