logging extension on data downloading

This commit is contained in:
DYefremov
2020-06-08 13:33:46 +03:00
parent 9a9229f67c
commit 20a1bac22e
2 changed files with 8 additions and 3 deletions

View File

@@ -2,7 +2,7 @@ import os
from gi.repository import GLib
from app.commons import run_idle, run_task
from app.commons import run_idle, run_task, log
from app.connections import download_data, DownloadType, upload_data
from app.settings import SettingsType
from app.ui.backup import backup_data, restore_data
@@ -171,8 +171,9 @@ class DownloadDialog:
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)
from traceback import format_exc
log("Downloading data error: {}".format(format_exc()))
self.show_info_message(str(e), Gtk.MessageType.ERROR)
if all((download, backup, data_path)):
restore_data(backup_src, data_path)
else:

View File

@@ -1039,6 +1039,8 @@ class Application(Gtk.Application):
download_type=DownloadType.ALL,
callback=lambda x: print(x, end=""))
except Exception as e:
from traceback import format_exc
log("Downloading data error: {}".format(format_exc()))
self.show_error_dialog(str(e))
else:
GLib.idle_add(self.open_data)
@@ -1063,6 +1065,8 @@ class Application(Gtk.Application):
callback=lambda x: print(x, end=""),
use_http=use_http)
except Exception as e:
from traceback import format_exc
log("Uploading data error: {}".format(format_exc()))
self.show_error_dialog(str(e))
def on_data_open(self, action=None, value=None):