Exemplo n.º 1
0
    def get_paged_data(self, api_function: Callable, expire_timedelta: timedelta, *args) -> List[Dict]:
        response = self.cache.get_response(ApiCommand(api_function, expire_timedelta, *args, page=1))
        try:
            pages = int(response.headers["x-pages"])
        except KeyError as e:
            return response.data

        data = response.data
        for page in range(2, pages + 1):
            items = self.cache.get_data(ApiCommand(api_function, expire_timedelta, *args, page=page))
            for item in items:
                if item:
                    data.append(item)
        return data
Exemplo n.º 2
0
 def get_fresh_data(self, api_command: ApiCommand,
                    etag: str) -> EsiResponse:
     response = api_command.get_api_response(etag)
     if int(response.status) == 304:
         return self.cache.get(api_command.key)
     elif int(response.status) == 200:
         self.cache.set(api_command.key, response,
                        api_command.expire_timedelta * self.time_dialation)
     return response
Exemplo n.º 3
0
def api_package_get_universe_system_kills(universe_api_class):
    yield ApiCommand(universe_api_class.get_universe_system_kills,
                     timedelta(seconds=0))
Exemplo n.º 4
0
def api_package_504():
    yield ApiCommand(get_504_gateway_timeout, timedelta(seconds=0))
Exemplo n.º 5
0
def api_package_503():
    yield ApiCommand(get_503_service_unavailable, timedelta(seconds=0))
Exemplo n.º 6
0
def api_package_502():
    yield ApiCommand(get_502_bad_gateway, timedelta(seconds=0))
Exemplo n.º 7
0
def api_package_500():
    yield ApiCommand(get_500_internal_server_error, timedelta(seconds=0))
Exemplo n.º 8
0
def api_package_420():
    yield ApiCommand(get_420_error_limited, timedelta(seconds=0))
Exemplo n.º 9
0
 def get_industry_system(self):
     return self.cache.get_data(ApiCommand(self.industry_api.get_industry_systems, timedelta(hours=1)))
Exemplo n.º 10
0
def api_package_403():
    yield ApiCommand(get_403_forbidden, timedelta(seconds=0))
Exemplo n.º 11
0
def api_package_401():
    yield ApiCommand(get_401_unauthorized, timedelta(seconds=0))
Exemplo n.º 12
0
def api_package_400():
    yield ApiCommand(get_400_bad_request, timedelta(seconds=0))
Exemplo n.º 13
0
 def get_universe_systems(self) -> List[int]:
     return self.cache.get_data(ApiCommand(self.universe_api.get_universe_systems, timedelta(days=30)))
Exemplo n.º 14
0
 def get_universe_system_kills(self) -> List[Dict]:
     return self.cache.get_data(ApiCommand(self.universe_api.get_universe_system_kills, timedelta(hours=1)))
Exemplo n.º 15
0
 def get_markets_prices(self) -> List[Dict]:
     return self.cache.get_data(ApiCommand(self.market_api.get_markets_prices, timedelta(hours=1)))
Exemplo n.º 16
0
def api_package_200():
    yield ApiCommand(get_200_ok, timedelta(seconds=60))
Exemplo n.º 17
0
def api_package_304():
    yield ApiCommand(get_304_not_modified, timedelta(seconds=60))
Exemplo n.º 18
0
def api_package_404():
    yield ApiCommand(get_404_page_not_exist, timedelta(seconds=0))