From 6188fecda95beb9539dcddfd7ead22b969347e1c Mon Sep 17 00:00:00 2001 From: DYefremov Date: Thu, 23 Dec 2021 22:07:06 +0300 Subject: [PATCH] reduced waiting time for web import --- app/tools/satellites.py | 6 +++--- app/ui/satellites.py | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/tools/satellites.py b/app/tools/satellites.py index d1e6b53f..470e3449 100644 --- a/app/tools/satellites.py +++ b/app/tools/satellites.py @@ -162,9 +162,9 @@ class SatellitesParser(HTMLParser): for src in SatelliteSource.get_sources(self._source): try: - request = requests.get(url=src, headers=_HEADERS) - except requests.exceptions.ConnectionError as e: - log(repr(e)) + request = requests.get(url=src, headers=_HEADERS, timeout=10) + except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout) as e: + log(f"Getting satellite list error: {repr(e)}") return [] else: reason = request.reason diff --git a/app/ui/satellites.py b/app/ui/satellites.py index fddb6727..6184fd21 100644 --- a/app/ui/satellites.py +++ b/app/ui/satellites.py @@ -532,8 +532,7 @@ class UpdateDialog: sat_src = SatelliteSource.KINGOFSAT sats = self._parser.get_satellites_list(sat_src) - if sats: - callback(sats) + callback(sats) self.is_download = False @run_idle @@ -814,7 +813,10 @@ class ServicesUpdateDialog(UpdateDialog): return appender.send(f"Getting services for: {t_names.get(futures[future], '')}.\n") - list(map(services.append, future.result())) + try: + list(map(services.append, future.result())) + except ValueError as e: + log(f"Getting services error: {e} [{t_names.get(futures[future])}]") appender.send("-" * 75 + "\n") appender.send(f"Consumed: {time.time() - start:0.0f}s, {len(services)} services received.") @@ -839,8 +841,7 @@ class ServicesUpdateDialog(UpdateDialog): self._services_parser.source = sat_src sats = self._parser.get_satellites_list(sat_src) - if sats: - callback(sats) + callback(sats) self.is_download = False def on_satellite_toggled(self, toggle, path):