Skip to content

Commit 28cde1a

Browse files
Implement review remarks
1 parent f59aa4e commit 28cde1a

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/askui/agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def __init__(
4444
self.client = None
4545
if enable_askui_controller:
4646
self.controller = AskUiControllerServer()
47-
self.controller.start(True, (logger.level == logging.DEBUG))
47+
self.controller.start(True, (logger.level < logging.INFO))
4848
time.sleep(0.5)
4949
self.client = AskUiControllerClient(display, self.report)
5050
self.client.connect()

src/askui/tools/askui/askui_controller.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ def _find_remote_device_controller(self) -> pathlib.Path:
7777

7878
def _find_remote_device_controller_by_component_registry(self) -> pathlib.Path:
7979
if self._settings.component_registry_file is None:
80-
raise AskUISuiteNotInstalledError('AskUI Suite not installed. Please install AskUI Suite to use AskUI Vision Agent.')
80+
raise AskUISuiteNotInstalledError(f"AskUI Suite is not installed. Please install AskUI Suite to use AskUI Vision Agent. For more information, please refer to 'https://docs.askui.com/introduction/01-introduction/02-quickstart'.")
8181
component_registry = AskUiComponentRegistry.model_validate_json(self._settings.component_registry_file.read_text())
8282
askui_remote_device_controller_path = component_registry.installed_packages.remote_device_controller_uuid.executables.askui_remote_device_controller
8383
if not os.path.isfile(askui_remote_device_controller_path):
8484
raise FileNotFoundError(f"AskUIRemoteDeviceController executable does not exits under '{askui_remote_device_controller_path}'")
8585
return askui_remote_device_controller_path
8686

87-
def __start_process(self, path, verbose: bool = False) -> None:
88-
if verbose:
87+
def __start_process(self, path, quite: bool = True) -> None:
88+
if not quite:
8989
self.process = subprocess.Popen(path)
9090
else:
9191
self.process = subprocess.Popen(
@@ -95,12 +95,12 @@ def __start_process(self, path, verbose: bool = False) -> None:
9595
)
9696
wait_for_port(23000)
9797

98-
def start(self, clean_up=False, verbose: bool = False) -> None:
98+
def start(self, clean_up=False, start_process_quite: bool = True) -> None:
9999
if sys.platform == 'win32' and clean_up and process_exists("AskuiRemoteDeviceController.exe"):
100100
self.clean_up()
101101
remote_device_controller_path = self._find_remote_device_controller()
102102
logger.debug("Starting AskUI Remote Device Controller: %s", remote_device_controller_path)
103-
self.__start_process(remote_device_controller_path, verbose=verbose)
103+
self.__start_process(remote_device_controller_path, quite=start_process_quite)
104104

105105
def clean_up(self):
106106
if sys.platform == 'win32':
@@ -333,16 +333,17 @@ def get_process_list(self, has_window:bool = False) -> List[controller_v1_pbs.Pr
333333
return response.processes
334334

335335
@telemetry.record_call(exclude_response = True)
336-
def get_windows_list(self, process_id: int) -> List[controller_v1_pbs.WindowInfo]:
337-
""""Get window list from the controller.
336+
def get_window_list_for_process_id(self, process_id: int) -> List[controller_v1_pbs.WindowInfo]:
337+
""""Get window list for a specific process ID from the controller.
338+
This method retrieves the list of windows associated with a given process ID.
338339
Args:
339340
process_id (int): Process ID to get windows for.
340341
Returns:
341342
List[controller_v1_pbs.WindowInfo]: List of window information objects.
342343
"""
343344
self._assert_stub_initialized()
344345
if self.report is not None:
345-
self.report.add_message("AgentOS", "get_windows_list()")
346+
self.report.add_message("AgentOS", f"get_window_list_for_process_id({process_id})")
346347
response = self.stub.GetWindowList(controller_v1_pbs.Request_GetWindowList(processID=process_id))
347348
return response.windows
348349

@@ -358,7 +359,7 @@ def get_all_window_names(self) -> List[str]:
358359
process_list = self.get_process_list(has_window=True)
359360
window_names = []
360361
for process in process_list:
361-
window_list = self.get_windows_list(process.ID)
362+
window_list = self.get_window_list_for_process_id(process.ID)
362363
for window in window_list:
363364
window_names.append(window.name)
364365
return window_names
@@ -388,7 +389,7 @@ def set_active_window_by_name(self, window_name: str) -> None:
388389
self.report.add_message("AgentOS", f"set_active_window_by_name({window_name})")
389390
process_list = self.get_process_list(has_window=True)
390391
for process in process_list:
391-
window_list = self.get_windows_list(process.ID)
392+
window_list = self.get_window_list_for_process_id(process.ID)
392393
for window in window_list:
393394
if window.name == window_name:
394395
self.set_active_window(window.ID, process.ID)

0 commit comments

Comments
 (0)