def __ppass(self, key, msg): main = lambda: getpass.getpass(msg) if self.cache is None: return main() elif isinstance(self.cache, str): cache = Cache(self.cache, disk_pickle_protocol=3) return cache.memoize(expire=self.time_expire, tag=key)(main)() else: return self.cache.disk(key, main, time_expire=self.time_expire)
time.sleep(retry_after + request_preroll * request_interval) # Raise so we get retried r.raise_for_status() else: try: r.raise_for_status() except Exception: print(f"<<<< REQUEST\n{r.request.__dict__}") print(f">>>> RESPONSE\n{r.__dict__}") raise # Sleep for 90% of the amortized rate limit time.sleep(0.9 * request_interval) return r.json() _get = cache.memoize()(_get_raw) @batched(100) def systems_get(systems): """Get a batch of systems, up to 100 (per the API).""" return _get( "https://www.edsm.net/api-v1/systems", params={ "systemName[]": systems, "showInformation": 1, "showPrimaryStar": 1, "showCoordinates": 1, }, )