Skip to content

Commit

Permalink
🐛 fix: fix Windows support for CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitrgadiya committed Jan 22, 2024
1 parent 55b05c6 commit 1fe926b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions riocli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion riocli/vpn/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit 1fe926b

Please sign in to comment.