diff --git a/app/connections.py b/app/connections.py index 6b362ef6..75e8e944 100644 --- a/app/connections.py +++ b/app/connections.py @@ -391,9 +391,10 @@ def download_data(*, settings, download_type=DownloadType.ALL, callback=log, fil callback("*** Done. ***") -def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False, - callback=log, done_callback=None, use_http=False, files_filter=None, ext_host=None): +def upload_data(*, settings, download_type=DownloadType.ALL, callback=log, done_callback=None, + files_filter=None, ext_host=None): s_type = settings.setting_type + use_http = s_type is SettingsType.ENIGMA_2 and settings.use_http data_path = settings.profile_data_path host, port, use_ssl = ext_host or settings.host, settings.http_port, settings.http_use_ssl user, password = settings.user, settings.password @@ -412,15 +413,7 @@ def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False if use_http: ht = http(user, password, base_url, callback, use_ssl, s_type) next(ht) - message = "" - if download_type is DownloadType.BOUQUETS: - message = "User bouquets will be updated!" - elif download_type is DownloadType.ALL: - message = "All user data will be reloaded!" - elif download_type is DownloadType.SATELLITES: - message = "Satellites.xml file will be updated!" - elif download_type is DownloadType.PICONS: - message = "Picons will be updated!" + message = get_upload_info_message(download_type) if s_type is SettingsType.ENIGMA_2: params = urlencode({"text": message, "type": 2, "timeout": 5}) @@ -431,7 +424,8 @@ def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False if s_type is SettingsType.ENIGMA_2 and download_type is DownloadType.ALL: time.sleep(5) - ht.send((f"{url}powerstate?newstate=0", "Toggle Standby ")) + if not settings.keep_power_mode: + ht.send((f"{url}powerstate?newstate=0", "Toggle Standby ")) time.sleep(2) else: if download_type is not DownloadType.PICONS: @@ -457,7 +451,7 @@ def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False if download_type is DownloadType.BOUQUETS: ftp.cwd(services_path) - ftp.upload_bouquets(data_path, remove_unused, callback) + ftp.upload_bouquets(data_path, settings.remove_unused_bouquets, callback) if download_type is DownloadType.ALL: ftp.upload_xml(data_path, sat_xml_path, STC_XML_FILE, callback) @@ -465,7 +459,7 @@ def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False ftp.upload_xml(data_path, sat_xml_path, WEB_TV_XML_FILE, callback) ftp.cwd(services_path) - ftp.upload_bouquets(data_path, remove_unused, callback) + ftp.upload_bouquets(data_path, settings.remove_unused_bouquets, callback) ftp.upload_files(data_path, DATA_FILES_LIST, callback) if download_type is DownloadType.PICONS: @@ -522,7 +516,8 @@ def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False ht.send((f"{url}servicelistreload?mode=2", "Reloading Userbouquets.")) elif download_type is DownloadType.ALL: ht.send((f"{url}servicelistreload?mode=0", "Reloading lamedb and Userbouquets.")) - ht.send((f"{url}powerstate?newstate=4", "Wakeup from Standby.")) + if not settings.keep_power_mode: + ht.send((f"{url}powerstate?newstate=4", "Wakeup from Standby.")) else: ht.send((f"{url}reloadchannels", "Reloading channels...")) @@ -535,6 +530,18 @@ def upload_data(*, settings, download_type=DownloadType.ALL, remove_unused=False ht.close() +def get_upload_info_message(download_type): + if download_type is DownloadType.BOUQUETS: + return "User bouquets will be updated!" + elif download_type is DownloadType.ALL: + return "All user data will be reloaded!" + elif download_type is DownloadType.SATELLITES: + return "Satellites.xml file will be updated!" + elif download_type is DownloadType.PICONS: + return "Picons will be updated!" + return "" + + # ***************** Picons *******************# def remove_picons(*, settings, callback=log, done_callback=None, files_filter=None): diff --git a/app/settings.py b/app/settings.py index 80059ae5..17afcea6 100644 --- a/app/settings.py +++ b/app/settings.py @@ -283,7 +283,7 @@ class Settings: @property def hosts(self): - return self._cp_settings.get("hosts", [self.host,]) + return self._cp_settings.get("hosts", [self.host, ]) @hosts.setter def hosts(self, value): @@ -833,6 +833,14 @@ class Settings: def remove_unused_bouquets(self, value): self._settings["remove_unused_bouquets"] = value + @property + def keep_power_mode(self): + return self._settings.get("keep_power_mode", False) + + @keep_power_mode.setter + def keep_power_mode(self, value): + self._settings["keep_power_mode"] = value + @property def compress_picons(self): return self._settings.get("compress_picons", False) diff --git a/app/ui/main.py b/app/ui/main.py index 8731e56c..4e940fa7 100644 --- a/app/ui/main.py +++ b/app/ui/main.py @@ -2052,16 +2052,13 @@ class Application(Gtk.Application): if multiple: log(f"##### Uploading data on [{host}] #####") try: - upload_data(settings=opts, - download_type=download_type, - remove_unused=True, - use_http=use_http, - ext_host=host) + upload_data(settings=opts, download_type=download_type, ext_host=host) except Exception as e: msg = "Uploading data error: {}" log(msg.format(e), debug=self._settings.debug_mode, fmt_message=msg) if host == self._settings.host: self.show_error_message(str(e)) + log(f"##### Done! #####") def on_data_open(self, action=None, value=None): """ Opening data via "File/Open". """ diff --git a/app/ui/settings_dialog.glade b/app/ui/settings_dialog.glade index 66546e32..2d08cf73 100644 --- a/app/ui/settings_dialog.glade +++ b/app/ui/settings_dialog.glade @@ -2733,7 +2733,7 @@ Author: Dmitriy Yefremov 0.019999999552965164 in - + True False @@ -2743,33 +2743,6 @@ Author: Dmitriy Yefremov 5 5 5 - - - True - False - Allows you to name bouquet files using their names. - start - True - Enable alternate bouquet file naming - - - 0 - 3 - - - - - True - True - Allows you to name bouquet files using their names. - end - - - - 1 - 3 - - True @@ -2818,6 +2791,33 @@ Author: Dmitriy Yefremov 1 + + + True + False + Allows you to name bouquet files using their names. + start + True + Enable alternate bouquet file naming + + + 0 + 4 + + + + + True + True + Allows you to name bouquet files using their names. + end + + + + 1 + 4 + + True @@ -2829,7 +2829,7 @@ Author: Dmitriy Yefremov 0 - 2 + 3 @@ -2838,6 +2838,33 @@ Author: Dmitriy Yefremov True Enables upload as an archive if a large number of picon (> 1000) is selected. Recommended only if you have external storage. + end + + + 1 + 3 + + + + + True + True + False + Don't toggle standby mode when updating bouquets and services. + Don't change power state + 0 + + + 0 + 2 + + + + + True + True + True + Don't toggle standby mode when updating bouquets and services. 1 @@ -3207,7 +3234,7 @@ Author: Dmitriy Yefremov save_button - + True False diff --git a/app/ui/settings_dialog.py b/app/ui/settings_dialog.py index db3debfd..5f7258b9 100644 --- a/app/ui/settings_dialog.py +++ b/app/ui/settings_dialog.py @@ -176,6 +176,7 @@ class SettingsDialog: # Extra. self._use_http_switch = builder.get_object("use_http_switch") self._remove_unused_bq_switch = builder.get_object("remove_unused_bq_switch") + self._keep_power_mode_switch = builder.get_object("keep_power_mode_switch") self._compress_picons_switch = builder.get_object("compress_picons_switch") self._force_bq_name_switch = builder.get_object("force_bq_name_switch") self._support_ver5_switch = builder.get_object("support_ver5_switch") @@ -348,6 +349,7 @@ class SettingsDialog: self._support_ver5_switch.set_active(self._settings.v5_support) self._use_http_switch.set_active(self._settings.use_http) self._remove_unused_bq_switch.set_active(self._settings.remove_unused_bouquets) + self._keep_power_mode_switch.set_active(self._settings.keep_power_mode) self._compress_picons_switch.set_active(self._settings.compress_picons) self._force_bq_name_switch.set_active(self._settings.force_bq_names) self._enable_yt_dl_switch.set_active(self._settings.enable_yt_dl) @@ -430,6 +432,7 @@ class SettingsDialog: self._ext_settings.v5_support = self._support_ver5_switch.get_active() self._ext_settings.use_http = self._use_http_switch.get_active() self._ext_settings.remove_unused_bouquets = self._remove_unused_bq_switch.get_active() + self._ext_settings.keep_power_mode = self._keep_power_mode_switch.get_active() self._ext_settings.compress_picons = self._compress_picons_switch.get_active() self._ext_settings.force_bq_names = self._force_bq_name_switch.get_active() self._ext_settings.enable_yt_dl = self._enable_yt_dl_switch.get_active()