diff --git a/Framework/install_handler/long_poll_handler.py b/Framework/install_handler/long_poll_handler.py index efcd61a5c..603638af3 100644 --- a/Framework/install_handler/long_poll_handler.py +++ b/Framework/install_handler/long_poll_handler.py @@ -3,6 +3,7 @@ import random import httpx import inspect +import platform from colorama import Fore from Framework.install_handler.route import Response, services from Framework.install_handler.utils import debug, send_response, read_node_id, generate_services_list @@ -39,8 +40,6 @@ async def on_message(self, message: Response) -> None: elif action == "system_info": if debug: print(f"[installer] Received system_info request") try: - # Get formatted system info - print("system info") system_info_response = await get_formatted_system_info() # Send the response to server await send_response({ @@ -126,7 +125,16 @@ async def on_message(self, message: Response) -> None: print(f"[installer] Function not found for {message.value.item.name}") return await func() - + elif action == "group_status": + services_list = [i for i in services if i["category"] == message.value.item.category][0]['services'] + functions = [i["status_function"] for i in services_list if i["status_function"]] + for func in functions: + await func() + elif action == "group_install": + services_list = [i for i in services if i["category"] == message.value.item.category][0]['services'] + functions = [i["install_function"] for i in services_list if i["install_function"]] + for func in functions: + await func() except Exception as e: traceback.print_exc() diff --git a/Framework/install_handler/route.py b/Framework/install_handler/route.py index e73adb869..7888aa0ef 100644 --- a/Framework/install_handler/route.py +++ b/Framework/install_handler/route.py @@ -1,5 +1,5 @@ from pydantic import BaseModel, ConfigDict -from typing import Literal +from typing import Literal, Optional import platform from .web import chrome_for_testing, edge, mozilla @@ -14,74 +14,81 @@ import datetime from Framework.install_handler.utils import debug -version = "2.0.0" services = [ { - "category": "Android", - "services": [ - { - "name": "Node js 22", - "status": "none", - "comment": "Node js 22 is a tool for managing Node js 22 devices.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": node_js_22.check_status, - "install_function": node_js_22.check_status, #on purpose. Node 22 is installed when node starts. - "user_password": "no", - }, - { - "name": "Appium", - "status": "none", - "comment": "Appium is a tool for managing Appium devices.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": appium.check_status, - "install_function": appium.check_status, #on purpose. Appium is installed when node starts. - "user_password": "no", - }, - { - "name": "Java", - "status": "none", - "comment": "Java is a tool for managing Java devices.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": java.check_status, - "install_function": java.install, #install jdk here also. jdk.install will install java also. - "user_password": "no" - }, - { - "name": "JDK", - "status": "none", - "comment": "JDK is a tool for managing JDK devices.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": jdk.check_status, - "install_function": jdk.install, - "user_password": "no" - }, - { - "name": "Android SDK", - "status": "none", - "comment": "Android SDK is a tool for managing Android SDK devices.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": android_sdk.check_status, - "install_function": android_sdk.install, - "user_password": "no" - }, - { - "name": "ADB", - "status": "none", - "comment": "ADB is a tool for managing Android devices.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": adb.check_status, - "install_function": adb.install, - "user_password": "no", - }, - ] - }, - { + "group":{ + "check_text": "check all", + "install_text": "install all", + }, + "category": "Android", + "services": [ + { + "name": "Node js 22", + "status": "none", + "comment": "Node js 22 is a tool for managing Node js 22 devices.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": node_js_22.check_status, + "install_function": node_js_22.check_status, #on purpose. Node 22 is installed when node starts. + "user_password": "no", + }, + { + "name": "Appium", + "status": "none", + "comment": "Appium is a tool for managing Appium devices.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": appium.check_status, + "install_function": appium.check_status, #on purpose. Appium is installed when node starts. + "user_password": "no", + }, + { + "name": "Java", + "status": "none", + "comment": "Java is a tool for managing Java devices.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": java.check_status, + "install_function": java.install, #install jdk here also. jdk.install will install java also. + "user_password": "no" + }, + { + "name": "JDK", + "status": "none", + "comment": "JDK is a tool for managing JDK devices.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": jdk.check_status, + "install_function": jdk.install, + "user_password": "no" + }, + { + "name": "Android SDK", + "status": "none", + "comment": "Android SDK is a tool for managing Android SDK devices.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": android_sdk.check_status, + "install_function": android_sdk.install, + "user_password": "no" + }, + { + "name": "ADB", + "status": "none", + "comment": "ADB is a tool for managing Android devices.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": adb.check_status, + "install_function": adb.install, + "user_password": "no", + }, + ] + }, + { + "group":{ + "check_text": "", + "install_text": "", + }, "category": "AndroidEmulator", "name" : "System Images", "install_text": "install", @@ -89,124 +96,139 @@ "installables": [], "services": [], }, - { - "category": "Web", - - "services": [ - { - "name": "Chrome For Testing", - "status": "none", - "comment": "Chrome for Testing is required to run web automation in Chrome browser.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": chrome_for_testing.check_status, - "install_function": chrome_for_testing.install, - "user_password": "no", - }, - { - "name": "Mozilla", - "status": "none", - "comment": "Mozilla Firefox is required to run web automation in Mozilla Firefox browser.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": mozilla.check_status, - "install_function": mozilla.install, - "user_password": "yes", - }, - { - "name": "Edge", - "status": "none", - "comment": "Microsoft Edge is required to run web automation in Microsoft Edge browser.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": edge.check_status, - "install_function": edge.install, - "user_password": "yes", - } - - ] - }, - { - "category": "iOS", - "services": [ - { - "name": "Xcode", - "status": "none", - "comment": "Xcode is a tool for managing Xcode devices.", - "install_text": "install", - "os": ["darwin"], - "status_function": xcode.check_status, - "install_function": xcode.install, - "user_password": "no" - } - ] - }, - { - "category": "Database", - "services": [ - { - "name": "PostgreSQL", - "status": "none", - "comment": "PostgreSQL driver is required to connect to PostgreSQL database.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": postgresql.check_status, - "install_function": postgresql.install, - "user_password": "no" - }, - { - "name": "MySQL", - "status": "none", - "comment": "MySQL driver is required to connect to MySQL database.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": mysql.check_status, - "install_function": mysql.install, - "user_password": "no" - }, - { - "name": "MariaDB", - "status": "none", - "comment": "MariaDB driver is required to connect to MariaDB database.", - "install_text": "install", - "os": ["windows", "linux", "darwin"], - "status_function": mariadb.check_status, - "install_function": mariadb.install, - "user_password": "yes" - }, - { - "name": "Oracle", - "status": "none", - "comment": "Oracle driver is required to connect to Oracle database.", - "install_text": "install", + { + "category": "Web", + "group":{ + "check_text": "check all", + "install_text": "install all", + }, + "services": [ + { + "name": "Chrome For Testing", + "status": "none", + "comment": "Chrome for Testing is required to run web automation in Chrome browser.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": chrome_for_testing.check_status, + "install_function": chrome_for_testing.install, + "user_password": "no", + }, + { + "name": "Mozilla", + "status": "none", + "comment": "Mozilla Firefox is required to run web automation in Mozilla Firefox browser.", + "install_text": "install", "os": ["windows", "linux", "darwin"], - "status_function": oracle.check_status, - "install_function": oracle.install, - "user_password": "no" - } - ] - }, - { - "category": "Windows", - "install_function": inspector.install, - "services": [ - { - "name": "Inspector", - "status": "none", - "comment": "Inspector is a tool for managing Inspector devices.", - "install_text": "install", - "os": ["windows"], - "status_function": inspector.check_status, - "install_function": inspector.install, - "user_password": "no" - } - ] - } + "status_function": mozilla.check_status, + "install_function": mozilla.install, + "user_password": "yes", + }, + { + "name": "Edge", + "status": "none", + "comment": "Microsoft Edge is required to run web automation in Microsoft Edge browser.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": edge.check_status, + "install_function": edge.install, + "user_password": "yes", + } + + ] + }, + { + "category": "iOS", + "group":{ + "check_text": "", + "install_text": "", + }, + "services": [ + { + "name": "Xcode", + "status": "none", + "comment": "Xcode is a tool for managing Xcode devices.", + "install_text": "install", + "os": ["darwin"], + "status_function": xcode.check_status, + "install_function": xcode.install, + "user_password": "no" + } + ] + }, + { + "category": "Database", + "group":{ + "check_text": "check all", + "install_text": "install all", + }, + "services": [ + { + "name": "PostgreSQL", + "status": "none", + "comment": "PostgreSQL driver is required to connect to PostgreSQL database.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": postgresql.check_status, + "install_function": postgresql.install, + "user_password": "no" + }, + { + "name": "MySQL", + "status": "none", + "comment": "MySQL driver is required to connect to MySQL database.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": mysql.check_status, + "install_function": mysql.install, + "user_password": "no" + }, + { + "name": "MariaDB", + "status": "none", + "comment": "MariaDB driver is required to connect to MariaDB database.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": mariadb.check_status, + "install_function": mariadb.install, + "user_password": "yes" + }, + { + "name": "Oracle", + "status": "none", + "comment": "Oracle driver is required to connect to Oracle database.", + "install_text": "install", + "os": ["windows", "linux", "darwin"], + "status_function": oracle.check_status, + "install_function": oracle.install, + "user_password": "no" + } + ] + }, + { + "category": "Windows", + "group":{ + "check_text": "", + "install_text": "", + }, + "install_function": inspector.install, + "services": [ + { + "name": "Inspector", + "status": "none", + "comment": "Inspector is a tool for managing Inspector devices.", + "install_text": "install", + "os": ["windows"], + "status_function": inspector.check_status, + "install_function": inspector.install, + "user_password": "no" + } + ] + } ] class Item(BaseModel): - name: str | None = None + name: Optional[str] = None category: str user_password: str = "" # Optional user password for installations requiring sudo/admin @@ -214,7 +236,7 @@ class Item(BaseModel): class Value(BaseModel): model_config = ConfigDict(extra='forbid') - action: Literal["services_list", "install", "status", "install_category", "system_info"] + action: Literal["services_list", "install", "status", "system_info", "group_status", "group_install"] item: Item | None = None diff --git a/Framework/install_handler/utils.py b/Framework/install_handler/utils.py index 59025f4d0..0b20460bf 100644 --- a/Framework/install_handler/utils.py +++ b/Framework/install_handler/utils.py @@ -17,6 +17,7 @@ def generate_services_list(services): filtered_services = [] for category in services: filtered_category = { + "group": category["group"], "category": category["category"], "services": [] } diff --git a/Framework/install_handler/windows/inspector.py b/Framework/install_handler/windows/inspector.py index a84b2b13c..68e3c9824 100644 --- a/Framework/install_handler/windows/inspector.py +++ b/Framework/install_handler/windows/inspector.py @@ -16,6 +16,7 @@ async def check_status() -> bool: "name": "Inspector", "status": "installed", "comment": f"Open the inspector here: {inspector_path}", + "install_text": "installed", } }) return True @@ -28,6 +29,7 @@ async def check_status() -> bool: "name": "Inspector", "status": "not installed", "comment": f"Install the inspector to use it.", + "install_text": "install", } }) return False @@ -45,6 +47,7 @@ async def install() -> bool: "name": "Inspector", "status": "installed", "comment": f"Open the inspector here: {inspector_path}", + "install_text": "installed", } }) print("[installer][windows-inspector] Already installed") @@ -89,6 +92,7 @@ async def install() -> bool: "name": "Inspector", "status": "installing", "comment": f"Downloading inspector... {progress:.1f}% ({mb_downloaded:.1f}/{mb_total:.1f} MB)", + "install_text": "installing", } })) @@ -102,6 +106,7 @@ async def install() -> bool: "name": "Inspector", "status": "installed", "comment": f"Open the inspector here: {inspector_path}", + "install_text": "installed", } }) return True