From 1fe926b88b1c1d387c9f79b3d912edbade1b3e1c Mon Sep 17 00:00:00 2001 From: Ankit R Gadiya Date: Thu, 18 Jan 2024 11:01:02 +0900 Subject: [PATCH] :bug: fix: fix Windows support for CLI Wrike Ticket: https://www.wrike.com/open.htm?id=1286610452 --- riocli/__init__.py | 8 ++++++++ riocli/vpn/util.py | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/riocli/__init__.py b/riocli/__init__.py index d2573146..ecff8f22 100644 --- a/riocli/__init__.py +++ b/riocli/__init__.py @@ -18,3 +18,11 @@ pretty_traceback.install() except ImportError: pass # no need to fail because of missing dev dependency + +# Patch `signal` to add SIGKILL for Windows. This is required for yaspin to work +# on windows. +from sys import platform + +if platform.lower() == 'win32': + import signal + signal.SIGKILL = signal.SIGTERM diff --git a/riocli/vpn/util.py b/riocli/vpn/util.py index 6c2f535e..1470960e 100644 --- a/riocli/vpn/util.py +++ b/riocli/vpn/util.py @@ -39,6 +39,8 @@ def get_host_name() -> str: def is_linux() -> bool: return platform.lower() == 'linux' +def is_windows() -> bool: + return platform.lower() == 'win32' def is_curl_installed() -> bool: return which('curl') is not None @@ -131,7 +133,7 @@ def is_vpn_enabled_in_project(client: v2Client, project_guid: str) -> bool: def get_command(cmd: str) -> str: """Returns an effective command to execute.""" - if is_linux() and os.geteuid() == 0: + if is_windows() or (is_linux() and os.geteuid() == 0): return cmd return 'sudo {}'.format(cmd)