Expand user directory on server /launch and /execute'

This commit is contained in:
BlankCheng
2024-01-29 21:52:27 +08:00
parent 7d2d8c855e
commit 80e08a2ff8

View File

@@ -45,6 +45,11 @@ def execute_command():
if isinstance(command, str) and not shell:
command = shlex.split(command)
# Expand user directory
for i, arg in enumerate(command):
if arg.startswith("~/"):
command[i] = os.path.expanduser(arg)
# Execute the command without any safety checks.
try:
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=shell, text=True)
@@ -82,6 +87,11 @@ def launch_app():
if isinstance(command, str) and not shell:
command = shlex.split(command)
# Expand user directory
for i, arg in enumerate(command):
if arg.startswith("~/"):
command[i] = os.path.expanduser(arg)
try:
if 'google-chrome' in command and _get_machine_architecture() == 'arm':
index = command.index('google-chrome')