diff --git a/app/tools/satellites.py b/app/tools/satellites.py index 687fd514..45c1ce7f 100644 --- a/app/tools/satellites.py +++ b/app/tools/satellites.py @@ -61,11 +61,9 @@ class SatellitesParser(HTMLParser): request = requests.get(url=self._url, headers=self._HEADERS) reason = request.reason if reason == "OK": - print(reason) self.feed(request.text) if self._rows: - for num, sat in enumerate(filter(lambda x: all(x) and len(x) == 5, self._rows)): - print(num + 1, sat) + return list(filter(lambda x: all(x) and len(x) == 5, self._rows)) else: print(reason) diff --git a/app/ui/tools.glade b/app/ui/tools.glade index adcf444b..a2daed3a 100644 --- a/app/ui/tools.glade +++ b/app/ui/tools.glade @@ -839,30 +839,63 @@ - - + + + + + + + + + + + + + + + + + + + + + + FlySat + + + + 480 False Satellites download tool + False True True dialog True - 320 False vertical 2 False - end + center - - - - + + gtk-close + True + True + True + True + True + + + True + True + 0 + @@ -876,22 +909,13 @@ True False vertical + 2 - - True - False - Not implemented yet! - - - False - True - 0 - - - - + True False + center + 2 True @@ -905,10 +929,17 @@ - + True False source_urls_list_store + 0 + + + + 0 + + False @@ -917,6 +948,17 @@ + + False + True + 0 + + + + + True + False + False True @@ -924,13 +966,76 @@ - - 100 + + 150 True True - satellites_list_store - - + in + + + 100 + True + True + satellites_list_store + + + + + + Satellite + + + + 0 + + + + + + + Position + + + + 1 + + + + + + + Type + + + + 2 + + + + + + + Url + + + + 3 + + + + + + + Selected + + + + 4 + + + + + @@ -940,16 +1045,57 @@ - + True False + + False + True + 3 + + + + + True + False + False + + + True + False + True + Receive + True + gtk-goto-bottom + + + + True + True + + + + False True 4 + + + True + False + + + False + True + 5 + + False diff --git a/app/ui/tools/satellites_downloader.py b/app/ui/tools/satellites_downloader.py index 17f3d503..32cdcc0f 100644 --- a/app/ui/tools/satellites_downloader.py +++ b/app/ui/tools/satellites_downloader.py @@ -1,10 +1,12 @@ -from app.ui.uicommons import Gtk, UI_RESOURCES_PATH, TEXT_DOMAIN +from app.commons import run_idle +from app.tools.satellites import SatellitesParser +from ..uicommons import Gtk, UI_RESOURCES_PATH, TEXT_DOMAIN class SatellitesDownloaderDialog: def __init__(self, transient, options): - handlers = {} + handlers = {"on_satellites_receive": self.on_satellites_receive} builder = Gtk.Builder() builder.set_translation_domain(TEXT_DOMAIN) @@ -19,6 +21,16 @@ class SatellitesDownloaderDialog: self._dialog.run() self._dialog.destroy() + @run_idle + def on_satellites_receive(self, item): + parser = SatellitesParser(url="https://www.flysat.com/satlist.php") + sats = parser.get_satellites() + if sats: + model = self._satellites_tree_view.get_model() + model.clear() + for sat in sats: + model.append((sat[1], sat[2], sat[3], sat[0], False)) + if __name__ == "__main__": pass