Пример #1
0
 async def __call_release_list_fun(self, generator_cache: GeneratorCache,
                                   app_id: dict, auth: dict or None):
     """ 当软件源未实现 get_release_list 函数时,缺省调用 get_release 函数获取数据的协程函数
     """
     # 获取云端数据
     release_list = None
     # noinspection PyBroadException
     try:
         release_list = self.get_release(app_id, auth)
         # 缓存数据,包括 404 None 数据
     except HTTPError as e:
         status_code = e.response.status_code
         logging.warning(f"""app_id: {app_id}
         HTTP CODE {status_code} ERROR: {e}""")
         if status_code == 404:
             release_list = []
     except asyncio.TimeoutError:
         logging.warning(f'app_id: {app_id} timeout!')
     except Exception:
         debug_mode = server_config.debug_mode
         log = f"app_id: {app_id}"
         if debug_mode:
             log += " \nERROR: "
         else:
             log += " ERROR"
         logging.exception(log, exc_info=debug_mode)
     return_value(generator_cache, app_id, release_list)
Пример #2
0
 def get_release(self,
                 hub_uuid: str,
                 app_id_list: list,
                 auth: dict or None = None,
                 use_cache=True,
                 cache_data=True) -> dict or None:
     if hub_uuid not in hub_dict:
         logging.warning(f"NO HUB: {hub_uuid}")
         return None
     return self.__get_release(hub_uuid, app_id_list, auth, use_cache,
                               cache_data)
Пример #3
0
 def init_account(hub_uuid: str, account: dict) -> dict or None:
     if hub_uuid not in hub_dict:
         logging.warning(f"NO HUB: {hub_uuid}")
         return None
     hub = hub_dict[hub_uuid]
     # noinspection PyBroadException
     try:
         return hub.init_account(account)
     except Exception:
         logging.error(f"""hub_uuid: {hub_uuid} \nERROR: """,
                       exc_info=server_config.debug_mode)
         return None
Пример #4
0
 def get_release(hub_uuid: str,
                 app_id_list: list,
                 auth: dict or None = None,
                 use_cache: bool = True,
                 cache_data: bool = True) -> dict or None:
     if hub_uuid not in hub_dict:
         logging.warning(f"NO HUB: {hub_uuid}")
         return None
     request_queue = send_getter_request(hub_uuid, app_id_list, auth,
                                         use_cache, cache_data)
     for app_id, release_list in request_queue:
         yield {"app_id": app_id, "release_list": release_list}
Пример #5
0
 def GetAppRelease(self, request: ReleaseRequest,
                   context) -> ReleaseResponse:
     hub_uuid: str = request.hub_uuid
     auth: dict = grcp_dict_list_to_dict(request.auth)
     app_id_list: list = [
         grcp_dict_list_to_dict(item.app_id) for item in request.app_id_list
     ]
     logging.warning(f"{hub_uuid}, num: {len(app_id_list)}, auth: {auth}")
     # noinspection PyBroadException
     try:
         for item in self.__get_app_release(hub_uuid, auth, app_id_list):
             yield item
     except Exception:
         logging.exception(f'gRPC: GetAppStatus, hub_uuid: {hub_uuid}')
         return None
Пример #6
0
 def get_download_info_list(hub_uuid: str, auth: dict, app_id: list,
                            asset_index: list) -> tuple or None:
     if hub_uuid not in hub_dict:
         logging.warning(f"NO HUB: {hub_uuid}")
         return None
     hub = hub_dict[hub_uuid]
     # noinspection PyBroadException
     try:
         download_info = hub.get_download_info(app_id, asset_index, auth)
         if type(download_info) is str:
             return [{"url": download_info}]
         else:
             return download_info
     except Exception:
         logging.error(f"""app_id: {app_id} \nERROR: """,
                       exc_info=server_config.debug_mode)
         return None