def download(self, download, d_type): """ Download/upload data from/to receiver """ try: self._expander.set_expanded(True) self.clear_output() if download: download_data(properties=self._profile_properties, download_type=d_type, callback=self.append_output) else: self.show_info_message(get_message("Please, wait..."), Gtk.MessageType.INFO) upload_data(properties=self._profile_properties, download_type=d_type, remove_unused=self._remove_unused_check_button. get_active(), profile=self._profile, callback=self.append_output, done_callback=lambda: self.show_info_message( get_message("Done!"), Gtk.MessageType.INFO), use_http=self._use_http_switch.get_active()) except Exception as e: message = str(getattr(e, "message", str(e))) self.show_info_message(message, Gtk.MessageType.ERROR) else: if download and d_type is not DownloadType.SATELLITES: GLib.idle_add(self._open_data_callback)
def download(self, download, d_type): """ Download/upload data from/to receiver """ GLib.idle_add(self._expander.set_expanded, True) self.clear_output() backup, backup_src, data_path = self._settings.backup_before_downloading, None, None try: if download: if backup and d_type is not DownloadType.SATELLITES: data_path = self._settings.data_local_path or self._data_path_entry.get_text() os.makedirs(os.path.dirname(data_path), exist_ok=True) backup_path = self._settings.backup_local_path or data_path + "backup/" backup_src = backup_data(data_path, backup_path, d_type is DownloadType.ALL) download_data(settings=self._settings, download_type=d_type, callback=self.append_output) else: self.show_info_message(get_message("Please, wait..."), Gtk.MessageType.INFO) upload_data(settings=self._settings, download_type=d_type, remove_unused=self._remove_unused_check_button.get_active(), callback=self.append_output, done_callback=lambda: self.show_info_message(get_message("Done!"), Gtk.MessageType.INFO), use_http=self._use_http_switch.get_active()) except Exception as e: msg = "Downloading data error: {}" log(msg.format(e), debug=self._settings.debug_mode, fmt_message=msg) self.show_info_message(str(e), Gtk.MessageType.ERROR) if all((download, backup, data_path)): restore_data(backup_src, data_path) else: if download and d_type is not DownloadType.SATELLITES: GLib.idle_add(self._open_data_callback)
def upload_picons(self): if self._current_process is not None and self._current_process.poll() is None: self.show_dialog("The task is already running!", DialogType.ERROR) return try: upload_data(properties=self._properties, download_type=DownloadType.PICONS, profile=self._profile, callback=lambda: self.show_info_message(get_message("Done!"), Gtk.MessageType.INFO)) except OSError as e: self.show_info_message(str(e), Gtk.MessageType.ERROR)
def on_send(self, item=None, files_filter=None, path=None): dest_path = path or self.check_dest_path() if not dest_path: return settings = Settings(self._settings.settings) settings.picons_local_path = "{}/".format(dest_path) self.show_info_message(get_message("Please, wait..."), Gtk.MessageType.INFO) self.run_func(lambda: upload_data( settings=settings, download_type=DownloadType.PICONS, callback=self.append_output, done_callback=lambda: self.show_info_message( get_message("Done!"), Gtk.MessageType.INFO), files_filter=files_filter))