def get_installed_app_details(dummy_app: InstallableApp) -> Union[dict, None]: installed_version: str = dummy_app.get_installed_version() if installed_version: status = systemctl_status(dummy_app.service_file_name) return { **dummy_app.to_property_dict(), **status, 'version': installed_version, 'service': dummy_app.service, } return None
def get_app_from_service(service, version_='') -> InstallableApp: try: if version_.upper() == 'LATEST': app: InstallableApp = InstallableApp.get_app(service, '') app.set_version(app.get_latest_release(get_github_token())) else: app: InstallableApp = InstallableApp.get_app(service, version_) if not version_ or version.parse(app.min_support_version) <= version.parse(app.version): return app raise NotFoundException(f'Your version need to be version >= {app.min_support_version}') except ModuleNotFoundError as e: raise NotFoundException(str(e))
def get_latest_app(cls, app: InstallableApp) -> dict: latest_version = None try: latest_version = app.get_latest_release(get_github_token()) except Exception as e: logger.error(str(e)) return latest_version
def validate_and_create_service_cmd(cls, action: str, service: str) -> str: try: app: InstallableApp = InstallableApp.get_app(service, "") return create_service_cmd(action, app.service_file_name) except ModuleNotFoundError: raise NotFoundException( f'App service {service} does not exist in our system')
def download_plugins_async(app_context, app: InstallableApp, args): if app_context: with app_context(): plugins = [] for arg in args: plugins.append(arg["plugin"].lower()) download_res = app.download_plugins(plugins) update_plugin_download_state(DownloadState.DOWNLOADED, app.service, app.version, download_res)
def get_installed_app_stat(cls, app: InstallableApp, get_browser_download_url: bool) -> dict: details: dict = {} is_installed: bool = False _browser_download_url = {} if systemctl_installed(app.service_file_name): details = get_installed_app_details(app) if details: is_installed = True app: InstallableApp = get_app_from_service(details['service']) app.set_version(details['version']) if get_browser_download_url: try: _browser_download_url = app.get_download_link( get_github_token(), True) except Exception as e: logger.error(str(e)) return { **(details if details else app.to_property_dict()), **_browser_download_url, 'service': app.service, 'is_installed': is_installed, }
from src.system.apps.base.installable_app import InstallableApp if __name__ == "__main__": app = InstallableApp.get_app('WIRES', 'v1.0.0') print(app.get_installation_dir()) app = InstallableApp.get_app('BACNET_SERVER', 'v1.0.0') print(app.get_installation_dir())
def validate_service(cls, service: str): try: InstallableApp.get_app(service, "") except ModuleNotFoundError: raise NotFoundException( f'App service {service} does not exist in our system')