From 80e08a2ff88ba4e7215f814d0aa9d728d7541738 Mon Sep 17 00:00:00 2001 From: BlankCheng <913501223@qq.com> Date: Mon, 29 Jan 2024 21:52:27 +0800 Subject: [PATCH] Expand user directory on server /launch and /execute' --- desktop_env/server/main.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/desktop_env/server/main.py b/desktop_env/server/main.py index f782781..9ed1295 100644 --- a/desktop_env/server/main.py +++ b/desktop_env/server/main.py @@ -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')