Merge remote-tracking branch 'origin/main'
# Conflicts: # desktop_env/controllers/setup.py
This commit is contained in:
@@ -197,8 +197,10 @@ class PythonController:
|
||||
if "text" not in parameters:
|
||||
raise Exception(f"Unknown parameters: {parameters}")
|
||||
# deal with special ' and \ characters
|
||||
text = parameters["text"].replace("\\", "\\\\").replace("'", "\\'")
|
||||
self.execute_python_command(f"pyautogui.typewrite('{text}')")
|
||||
# text = parameters["text"].replace("\\", "\\\\").replace("'", "\\'")
|
||||
# self.execute_python_command(f"pyautogui.typewrite('{text}')")
|
||||
text = parameters["text"]
|
||||
self.execute_python_command("pyautogui.typewrite({:})".format(repr(text)))
|
||||
|
||||
elif action_type == "PRESS":
|
||||
if "key" not in parameters:
|
||||
|
||||
@@ -205,11 +205,15 @@ class SetupController:
|
||||
except requests.exceptions.RequestException as e:
|
||||
logger.error("An error occurred while trying to send the request: %s", e)
|
||||
|
||||
def _launch_setup(self, command: Union[str, List[str]]):
|
||||
def _launch_setup(self, command: Union[str, List[str]], shell: bool = False):
|
||||
if not command:
|
||||
raise Exception("Empty command to launch.")
|
||||
|
||||
payload = json.dumps({"command": command})
|
||||
if not shell and isinstance(command, str) and len(command.split()) > 1:
|
||||
logger.warning("Command should be a list of strings. Now it is a string. Will split it by space.")
|
||||
command = command.split()
|
||||
|
||||
payload = json.dumps({"command": command, "shell": shell})
|
||||
headers = {"Content-Type": "application/json"}
|
||||
|
||||
try:
|
||||
@@ -241,7 +245,7 @@ class SetupController:
|
||||
|
||||
while not terminates:
|
||||
try:
|
||||
response = requests.post(self.http_server_setup_root + "/execute", headers=headers, data=payload)
|
||||
response = requests.post(self.http_server + "/setup" + "/execute", headers=headers, data=payload)
|
||||
if response.status_code == 200:
|
||||
results: Dict[str, str] = response.json()
|
||||
if stdout:
|
||||
|
||||
Reference in New Issue
Block a user