computer-use-ootb-internal 0.0.111__py3-none-any.whl → 0.0.112__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.
- computer_use_ootb_internal/app_teachmode.py +44 -62
- computer_use_ootb_internal/guard_service.py +1 -1
- computer_use_ootb_internal/preparation/__init__.py +1 -0
- computer_use_ootb_internal/preparation/star_rail_prepare.py +65 -0
- {computer_use_ootb_internal-0.0.111.dist-info → computer_use_ootb_internal-0.0.112.dist-info}/METADATA +1 -1
- {computer_use_ootb_internal-0.0.111.dist-info → computer_use_ootb_internal-0.0.112.dist-info}/RECORD +8 -6
- {computer_use_ootb_internal-0.0.111.dist-info → computer_use_ootb_internal-0.0.112.dist-info}/WHEEL +0 -0
- {computer_use_ootb_internal-0.0.111.dist-info → computer_use_ootb_internal-0.0.112.dist-info}/entry_points.txt +0 -0
@@ -8,6 +8,9 @@ import platform # Add platform import
|
|
8
8
|
import pyautogui # Add pyautogui import
|
9
9
|
import webbrowser # Add webbrowser import
|
10
10
|
import os # Import os for path joining
|
11
|
+
import logging # Import logging
|
12
|
+
import importlib # For dynamic imports
|
13
|
+
import pkgutil # To find modules
|
11
14
|
from fastapi import FastAPI, Request
|
12
15
|
from fastapi.responses import JSONResponse
|
13
16
|
from fastapi.middleware.cors import CORSMiddleware
|
@@ -90,68 +93,47 @@ class SharedState:
|
|
90
93
|
shared_state = None
|
91
94
|
rate_limiter = RateLimiter(interval_seconds=2)
|
92
95
|
|
93
|
-
#
|
96
|
+
# Set up logging for this module
|
97
|
+
log = logging.getLogger(__name__)
|
98
|
+
|
94
99
|
def prepare_environment(state):
|
95
|
-
"""
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
# Disable failsafe before clicking
|
134
|
-
pyautogui.FAILSAFE = False
|
135
|
-
print("PyAutoGUI failsafe temporarily disabled.")
|
136
|
-
|
137
|
-
print(f"Clicking at coordinates: ({click_x}, {click_y})")
|
138
|
-
pyautogui.click(click_x, click_y)
|
139
|
-
time.sleep(2)
|
140
|
-
pyautogui.click(click_x, click_y)
|
141
|
-
|
142
|
-
# Re-enable failsafe (optional, as script might end anyway)
|
143
|
-
# pyautogui.FAILSAFE = True
|
144
|
-
# print("PyAutoGUI failsafe re-enabled.")
|
145
|
-
|
146
|
-
except Exception as e:
|
147
|
-
print(f"Error during environment preparation (browser/click): {e}")
|
148
|
-
finally:
|
149
|
-
# Ensure failsafe is re-enabled if an error occurs after disabling it
|
150
|
-
pyautogui.FAILSAFE = True
|
151
|
-
print("PyAutoGUI failsafe re-enabled.")
|
152
|
-
else:
|
153
|
-
# Placeholder for potential preparations on other OS or non-Star Rail modes
|
154
|
-
print("Environment preparation: No specific actions required for this OS/mode.")
|
100
|
+
"""Dynamically loads and runs preparation logic based on software name."""
|
101
|
+
# TODO: Replace hardcoded software name with value from shared_state when available
|
102
|
+
software_name = "star rail"
|
103
|
+
# Normalize the software name to be a valid Python module name
|
104
|
+
# Replace spaces/hyphens with underscores, convert to lowercase
|
105
|
+
module_name_base = software_name.replace(" ", "_").replace("-", "_").lower()
|
106
|
+
module_to_run = f"{module_name_base}_prepare"
|
107
|
+
|
108
|
+
log.info(f"Attempting preparation for software: '{software_name}' (Module: '{module_to_run}')")
|
109
|
+
|
110
|
+
try:
|
111
|
+
# Construct the full module path within the package
|
112
|
+
prep_package = "computer_use_ootb_internal.preparation"
|
113
|
+
full_module_path = f"{prep_package}.{module_to_run}"
|
114
|
+
|
115
|
+
# Dynamically import the module
|
116
|
+
# Check if module exists first using pkgutil to avoid import errors
|
117
|
+
# Note: pkgutil.find_loader might be deprecated, consider importlib.util.find_spec
|
118
|
+
loader = pkgutil.find_loader(full_module_path)
|
119
|
+
if loader is None:
|
120
|
+
log.warning(f"Preparation module '{full_module_path}' not found. Skipping preparation.")
|
121
|
+
return
|
122
|
+
|
123
|
+
prep_module = importlib.import_module(full_module_path)
|
124
|
+
|
125
|
+
# Check if the module has the expected function
|
126
|
+
if hasattr(prep_module, "run_preparation") and callable(prep_module.run_preparation):
|
127
|
+
log.info(f"Running preparation function from {full_module_path}...")
|
128
|
+
prep_module.run_preparation(state)
|
129
|
+
log.info(f"Preparation function from {full_module_path} completed.")
|
130
|
+
else:
|
131
|
+
log.warning(f"Module {full_module_path} found, but does not have a callable 'run_preparation' function. Skipping.")
|
132
|
+
|
133
|
+
except ModuleNotFoundError:
|
134
|
+
log.warning(f"Preparation module '{full_module_path}' not found. Skipping preparation.")
|
135
|
+
except Exception as e:
|
136
|
+
log.error(f"Error during dynamic preparation loading/execution for '{module_to_run}': {e}", exc_info=True)
|
155
137
|
|
156
138
|
|
157
139
|
@app.post("/update_params")
|
@@ -178,7 +160,7 @@ async def update_parameters(request: Request):
|
|
178
160
|
|
179
161
|
log_ootb_request(shared_state.server_url, "update_params", data)
|
180
162
|
|
181
|
-
# Call the preparation function here, after parameters are updated
|
163
|
+
# Call the (now dynamic) preparation function here, after parameters are updated
|
182
164
|
prepare_environment(shared_state)
|
183
165
|
|
184
166
|
return JSONResponse(
|
@@ -31,7 +31,7 @@ _PACKAGE_NAME = "computer-use-ootb-internal"
|
|
31
31
|
# Main module to start/stop for users
|
32
32
|
_OOTB_MODULE = "computer_use_ootb_internal.app_teachmode"
|
33
33
|
# Server endpoint to poll for commands (replace with your actual URL)
|
34
|
-
_SERVER_COMMAND_URL = "
|
34
|
+
_SERVER_COMMAND_URL = "http://52.160.105.102:7000/api/guard" # Using HTTP as port was specified
|
35
35
|
# How often to poll the server (in seconds)
|
36
36
|
_POLLING_INTERVAL = 60
|
37
37
|
# Placeholder for a machine identifier or API key for the server
|
@@ -0,0 +1 @@
|
|
1
|
+
# This file makes the 'preparation' directory a Python package
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# src/computer_use_ootb_internal/preparation/star_rail_prepare.py
|
2
|
+
import time
|
3
|
+
import platform
|
4
|
+
import pyautogui
|
5
|
+
import webbrowser
|
6
|
+
import logging # Use logging instead of print for better practice
|
7
|
+
|
8
|
+
# Set up logging for this module if needed, or rely on root logger
|
9
|
+
log = logging.getLogger(__name__)
|
10
|
+
|
11
|
+
def run_preparation(state):
|
12
|
+
"""
|
13
|
+
Performs environment preparation specific to Star Rail on Windows.
|
14
|
+
Opens the specified URL in Edge and performs initial clicks.
|
15
|
+
"""
|
16
|
+
if platform.system() != "Windows":
|
17
|
+
log.info("Star Rail preparation skipped: Not running on Windows.")
|
18
|
+
return
|
19
|
+
|
20
|
+
log.info("Star Rail preparation: Starting environment setup on Windows...")
|
21
|
+
url = "https://sr.mihoyo.com/cloud/#/" # Consider making this configurable later
|
22
|
+
browser_opened = False
|
23
|
+
try:
|
24
|
+
# Use only webbrowser.open
|
25
|
+
log.info(f"Attempting to open {url} using webbrowser.open()...")
|
26
|
+
if webbrowser.open(url):
|
27
|
+
log.info(f"Successfully requested browser to open {url} via webbrowser.open().")
|
28
|
+
browser_opened = True
|
29
|
+
else:
|
30
|
+
log.warning("webbrowser.open() returned False, indicating potential failure.")
|
31
|
+
|
32
|
+
if not browser_opened:
|
33
|
+
log.error("Failed to confirm browser opening via webbrowser.open(). Will still attempt clicks.")
|
34
|
+
|
35
|
+
# Add pyautogui click after attempting to open the browser
|
36
|
+
log.info("Proceeding with pyautogui actions...")
|
37
|
+
time.sleep(5) # Wait time for the browser to load
|
38
|
+
|
39
|
+
# Get screen size
|
40
|
+
screen_width, screen_height = pyautogui.size()
|
41
|
+
log.info(f"Detected screen size: {screen_width}x{screen_height}")
|
42
|
+
|
43
|
+
# Calculate click coordinates based on a reference resolution (e.g., 1280x720)
|
44
|
+
# TODO: Make these coordinates more robust or configurable
|
45
|
+
click_x = int(screen_width * (1036 / 1280))
|
46
|
+
click_y = int(screen_height * (500 / 720))
|
47
|
+
log.info(f"Calculated click coordinates: ({click_x}, {click_y})")
|
48
|
+
|
49
|
+
# Disable failsafe before clicking
|
50
|
+
pyautogui.FAILSAFE = False
|
51
|
+
log.info("PyAutoGUI failsafe temporarily disabled.")
|
52
|
+
|
53
|
+
log.info(f"Clicking at coordinates: ({click_x}, {click_y})")
|
54
|
+
pyautogui.click(click_x, click_y)
|
55
|
+
time.sleep(2)
|
56
|
+
pyautogui.click(click_x, click_y) # Double click?
|
57
|
+
|
58
|
+
log.info("Star Rail preparation clicks completed.")
|
59
|
+
|
60
|
+
except Exception as e:
|
61
|
+
log.error(f"Error during Star Rail preparation (browser/click): {e}", exc_info=True)
|
62
|
+
finally:
|
63
|
+
# Ensure failsafe is re-enabled
|
64
|
+
pyautogui.FAILSAFE = True
|
65
|
+
log.info("PyAutoGUI failsafe re-enabled.")
|
{computer_use_ootb_internal-0.0.111.dist-info → computer_use_ootb_internal-0.0.112.dist-info}/RECORD
RENAMED
@@ -1,9 +1,9 @@
|
|
1
1
|
computer_use_ootb_internal/README.md,sha256=FxpW95lyub2iX73ZDfK6ML7SdEKg060H5I6Grub7li4,31
|
2
2
|
computer_use_ootb_internal/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
|
3
|
-
computer_use_ootb_internal/app_teachmode.py,sha256=
|
3
|
+
computer_use_ootb_internal/app_teachmode.py,sha256=U0vHAEHeDMDioYatLQkzesT1Hy0aI6kKjhAlV86zxfc,17902
|
4
4
|
computer_use_ootb_internal/app_teachmode_gradio.py,sha256=cmFpBrkdlZxOQADWveVdIaaNqaBD8IVs-xNLJogU7F8,7909
|
5
5
|
computer_use_ootb_internal/dependency_check.py,sha256=y8RMEP6RXQzTgU1MS_1piBLtz4J-Hfn9RjUZg59dyvo,1333
|
6
|
-
computer_use_ootb_internal/guard_service.py,sha256=
|
6
|
+
computer_use_ootb_internal/guard_service.py,sha256=bTzBQMnHYaUXBwCWcnn0cXBPJyKl26-LVRIRB-fiRzo,20558
|
7
7
|
computer_use_ootb_internal/requirements-lite.txt,sha256=5DAHomz4A_P2BmTIXNkNqkHbnIF0AyZ4_1XAlb1LaYs,290
|
8
8
|
computer_use_ootb_internal/run_teachmode_ootb_args.py,sha256=7Dj0iY4GG7P03tRKYJ2x9Yvt-PE-b7uyjCAed3SaF3Y,7086
|
9
9
|
computer_use_ootb_internal/service_manager.py,sha256=sesbSUBBqm6W77Dykaw-HGARU-yNdK9DqOHPiR2TbkE,6920
|
@@ -32,7 +32,9 @@ computer_use_ootb_internal/computer_use_demo/tools/computer_marbot.py,sha256=zZu
|
|
32
32
|
computer_use_ootb_internal/computer_use_demo/tools/edit.py,sha256=b0PwUitxckHCQqFP3ZwlthWdqNkn7WETeTHeB6-o98c,11486
|
33
33
|
computer_use_ootb_internal/computer_use_demo/tools/run.py,sha256=xhXdnBK1di9muaO44CEirL9hpGy3NmKbjfMpyeVmn8Y,1595
|
34
34
|
computer_use_ootb_internal/computer_use_demo/tools/screen_capture.py,sha256=L8qfvtUkPPQGt92N-2Zfw5ZTDBzLsDps39uMnX3_uSA,6857
|
35
|
-
computer_use_ootb_internal
|
36
|
-
computer_use_ootb_internal
|
37
|
-
computer_use_ootb_internal-0.0.
|
38
|
-
computer_use_ootb_internal-0.0.
|
35
|
+
computer_use_ootb_internal/preparation/__init__.py,sha256=AgtGHcBpiTkxJjF0xwcs3yyQ6SyUvhL3G0vD2XO-zJw,63
|
36
|
+
computer_use_ootb_internal/preparation/star_rail_prepare.py,sha256=s1VWszcTnJAKxqCHFlaOEwPkqVSrkiFx_yKpWSnSbHs,2649
|
37
|
+
computer_use_ootb_internal-0.0.112.dist-info/METADATA,sha256=P4zVajg7g2i1wpHYk98DU4M9JawiqWp4mKz7crW9qSM,993
|
38
|
+
computer_use_ootb_internal-0.0.112.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
39
|
+
computer_use_ootb_internal-0.0.112.dist-info/entry_points.txt,sha256=bXfyAU_qq-G1EiEgAQEioXvgEdRCFxaTooqdDD9Y4OA,258
|
40
|
+
computer_use_ootb_internal-0.0.112.dist-info/RECORD,,
|
{computer_use_ootb_internal-0.0.111.dist-info → computer_use_ootb_internal-0.0.112.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|