enabled data transfer from ext path

This commit is contained in:
DYefremov
2025-08-30 00:09:31 +03:00
parent f85c1d2e0d
commit 8bf6427bbd
2 changed files with 11 additions and 13 deletions

View File

@@ -460,10 +460,9 @@ def download_data(*, settings, download_type=DownloadType.ALL, callback=log, fil
def upload_data(*, settings, download_type=DownloadType.ALL, callback=log, done_callback=None,
files_filter=None, ext_host=None):
files_filter=None, ext_host=None, ext_path=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
base_url = f"http{'s' if use_ssl else ''}://{host}:{port}"
@@ -471,6 +470,7 @@ def upload_data(*, settings, download_type=DownloadType.ALL, callback=log, done_
url = f"{base_url}/{base}/"
tn, ht = None, None # Telnet, HTTP.
ftp_port, telnet_port = settings.port, settings.telnet_port
data_path = ext_path or settings.profile_data_path
try:
use_http = use_http and test_http(host, port, user, password, use_ssl=use_ssl, skip_message=True, s_type=s_type)
@@ -588,7 +588,7 @@ def upload_data(*, settings, download_type=DownloadType.ALL, callback=log, done_
ht.send((f"{url}servicelistreload?mode=2", "Reloading Userbouquets."))
elif download_type is DownloadType.ALL or download_type is DownloadType.SERVICES:
ht.send((f"{url}servicelistreload?mode=0", "Reloading lamedb and Userbouquets."))
time.sleep(1)
time.sleep(2)
ht.send((f"{url}servicelistreload?mode=4", "Updating parental control."))
if not settings.keep_power_mode:
ht.send((f"{url}powerstate?newstate=4", "Wakeup from Standby."))

View File

@@ -248,6 +248,7 @@ class Application(Gtk.Application):
self._is_data_open_enabled = True
self._is_data_extract_enabled = False
self._is_data_save_enabled = False
self._ext_data_path = None
# Used for copy/paste. When adding the previous data will not be deleted.
# Clearing only after the insertion!
self._rows_buffer = []
@@ -2243,14 +2244,18 @@ class Application(Gtk.Application):
self.upload_data(download_type)
@run_task
def upload_data(self, download_type):
def upload_data(self, download_type, files_filter=None):
opts = self._settings
multiple = len(self._settings.hosts) > 1
for host in self._settings.hosts:
if multiple:
log(f"##### Uploading data on [{host}] #####")
try:
upload_data(settings=opts, download_type=download_type, ext_host=host)
upload_data(settings=opts,
download_type=download_type,
files_filter=files_filter,
ext_host=host,
ext_path=self._ext_data_path)
except Exception as e:
msg = "Uploading data error: {}"
log(msg.format(e), debug=self._settings.debug_mode, fmt_message=msg)
@@ -2333,6 +2338,7 @@ class Application(Gtk.Application):
return tmp_path
def update_data(self, data_path, callback=None):
self._ext_data_path = data_path
self._services_load_spinner.start()
self.on_info_bar_close()
self._profile_combo_box.set_sensitive(False)
@@ -2359,14 +2365,6 @@ class Application(Gtk.Application):
local_path = self._settings.profile_data_path
os.makedirs(os.path.dirname(local_path), exist_ok=True)
if data_path != local_path:
from shutil import copyfile
for f in STC_XML_FILE:
xml_src = data_path + f
if os.path.isfile(xml_src):
copyfile(xml_src, local_path + f)
prf = self._s_type
black_list = get_blacklist(data_path)
self._stream_relay.refresh(data_path)