computer-use-ootb-internal 0.0.100.post1__py3-none-any.whl → 0.0.102.post1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@ import platform # Add platform import
8
8
  import subprocess # Add subprocess import
9
9
  import pyautogui # Add pyautogui import
10
10
  import webbrowser # Add webbrowser import
11
+ import os # Import os for path joining
11
12
  from fastapi import FastAPI, Request
12
13
  from fastapi.responses import JSONResponse
13
14
  from fastapi.middleware.cors import CORSMiddleware
@@ -104,14 +105,50 @@ def prepare_environment(state):
104
105
  if is_star_rail:
105
106
  print("Star Rail mode detected on Windows. Opening Edge browser...")
106
107
  url = "https://sr.mihoyo.com/cloud/#/"
108
+ browser_opened = False
107
109
  try:
108
- # Use webbrowser.open to open the URL in the default browser
109
- print(f"Attempting to open {url} in browser...")
110
- webbrowser.open(url)
111
- print(f"Successfully requested browser to open {url}")
112
-
113
- # Add pyautogui click after opening the browser
114
- time.sleep(5) # Increased wait time for the browser to load
110
+ print(f"Attempting to open {url} using specific Edge paths...")
111
+ # Common paths for msedge.exe
112
+ edge_paths = [
113
+ os.path.join(os.environ.get("ProgramFiles(x86)", "C:\Program Files (x86)"), "Microsoft\Edge\Application\msedge.exe"),
114
+ os.path.join(os.environ.get("ProgramFiles", "C:\Program Files"), "Microsoft\Edge\Application\msedge.exe")
115
+ ]
116
+
117
+ opened_with_subprocess = False
118
+ for edge_path in edge_paths:
119
+ if os.path.exists(edge_path):
120
+ try:
121
+ print(f"Trying path: {edge_path}")
122
+ subprocess.Popen([edge_path, url])
123
+ print(f"Successfully launched Edge with Popen using path: {edge_path}")
124
+ opened_with_subprocess = True
125
+ browser_opened = True
126
+ break # Exit loop once successfully opened
127
+ except Exception as sub_e:
128
+ print(f"Failed to launch Edge with Popen using {edge_path}: {sub_e}")
129
+ else:
130
+ print(f"Edge path not found: {edge_path}")
131
+
132
+ # Fallback to webbrowser.open if subprocess failed
133
+ if not opened_with_subprocess:
134
+ print("Subprocess launch failed, falling back to webbrowser.open()...")
135
+ try:
136
+ if webbrowser.open(url):
137
+ print("Successfully opened browser using webbrowser.open() as fallback.")
138
+ browser_opened = True
139
+ else:
140
+ print("webbrowser.open() also failed to indicate success.")
141
+ except Exception as web_e:
142
+ print(f"webbrowser.open() fallback failed: {web_e}")
143
+
144
+ if not browser_opened:
145
+ print("ERROR: Failed to open browser using both subprocess and webbrowser.")
146
+ # Decide if you want to proceed without the browser or raise an error
147
+ # For now, we'll proceed to the click attempt but it might fail
148
+
149
+ # Add pyautogui click after attempting to open the browser
150
+ print("Proceeding with pyautogui actions...")
151
+ time.sleep(5) # Wait time for the browser to load
115
152
 
116
153
  # Print detected screen size
117
154
  screen_width, screen_height = pyautogui.size()
@@ -127,19 +164,22 @@ def prepare_environment(state):
127
164
 
128
165
  print(f"Clicking at coordinates: ({click_x}, {click_y})")
129
166
  pyautogui.click(click_x, click_y)
167
+ time.sleep(2)
168
+ pyautogui.click(click_x, click_y)
130
169
 
131
170
  # Re-enable failsafe (optional, as script might end anyway)
132
171
  # pyautogui.FAILSAFE = True
133
172
  # print("PyAutoGUI failsafe re-enabled.")
134
173
 
135
174
  except FileNotFoundError:
136
- # This error is less likely with webbrowser.open
137
- print("Error: Could not find a web browser to open the URL.")
175
+ # This specific error might occur if edge_path exists but execution fails
176
+ print("Error: Could not execute the browser command (FileNotFound). Check permissions or path.")
138
177
  except Exception as e:
139
178
  print(f"Error during environment preparation (browser/click): {e}")
140
179
  finally:
141
180
  # Ensure failsafe is re-enabled if an error occurs after disabling it
142
181
  pyautogui.FAILSAFE = True
182
+ print("PyAutoGUI failsafe re-enabled.")
143
183
  else:
144
184
  # Placeholder for potential preparations on other OS or non-Star Rail modes
145
185
  print("Environment preparation: No specific actions required for this OS/mode.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: computer-use-ootb-internal
3
- Version: 0.0.100.post1
3
+ Version: 0.0.102.post1
4
4
  Summary: Computer Use OOTB
5
5
  Author-email: Siyuan Hu <siyuan.hu.sg@gmail.com>
6
6
  Requires-Python: >=3.11
@@ -1,5 +1,5 @@
1
1
  computer_use_ootb_internal/README.md,sha256=FxpW95lyub2iX73ZDfK6ML7SdEKg060H5I6Grub7li4,31
2
- computer_use_ootb_internal/app_teachmode.py,sha256=Ya8EnJAA6YfkcbaSEtoiGQ39_63IzJj1yawaSBuoZuk,18613
2
+ computer_use_ootb_internal/app_teachmode.py,sha256=k4Y5ecIPmgQrtBkSV_xPHb0C6tssdEWfqI7uQsW2ku8,20963
3
3
  computer_use_ootb_internal/app_teachmode_gradio.py,sha256=zAw-n3s20j1Jr0S4TzXHwllKV6APJ8HEHB1KqBuzriY,7907
4
4
  computer_use_ootb_internal/dependency_check.py,sha256=y8RMEP6RXQzTgU1MS_1piBLtz4J-Hfn9RjUZg59dyvo,1333
5
5
  computer_use_ootb_internal/example_websocket_js.html,sha256=BLYwDExVlgiAX4vXVXW3RuP5KD8FXE4EFXIl54bwF7w,1322
@@ -38,7 +38,7 @@ computer_use_ootb_internal/computer_use_demo/tools/computer_marbot.py,sha256=zZu
38
38
  computer_use_ootb_internal/computer_use_demo/tools/edit.py,sha256=b0PwUitxckHCQqFP3ZwlthWdqNkn7WETeTHeB6-o98c,11486
39
39
  computer_use_ootb_internal/computer_use_demo/tools/run.py,sha256=xhXdnBK1di9muaO44CEirL9hpGy3NmKbjfMpyeVmn8Y,1595
40
40
  computer_use_ootb_internal/computer_use_demo/tools/screen_capture.py,sha256=L8qfvtUkPPQGt92N-2Zfw5ZTDBzLsDps39uMnX3_uSA,6857
41
- computer_use_ootb_internal-0.0.100.post1.dist-info/METADATA,sha256=ascLHbLvpwRApjH4FAoNsNuES-GNyoIm5pmc96lqNWQ,943
42
- computer_use_ootb_internal-0.0.100.post1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
43
- computer_use_ootb_internal-0.0.100.post1.dist-info/entry_points.txt,sha256=-AbmawU7IRQuDZihgVMVDrFoY4E6rnXYOUB-5vSeBKs,93
44
- computer_use_ootb_internal-0.0.100.post1.dist-info/RECORD,,
41
+ computer_use_ootb_internal-0.0.102.post1.dist-info/METADATA,sha256=Wu4c7JCwLWtGWf96CQAh37Pfs4y8Rf1lOO_Jc4jnXEc,943
42
+ computer_use_ootb_internal-0.0.102.post1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
43
+ computer_use_ootb_internal-0.0.102.post1.dist-info/entry_points.txt,sha256=-AbmawU7IRQuDZihgVMVDrFoY4E6rnXYOUB-5vSeBKs,93
44
+ computer_use_ootb_internal-0.0.102.post1.dist-info/RECORD,,