From c0a42b756be0494e3b45d539f68c0f5269c858de Mon Sep 17 00:00:00 2001 From: SomberNight Date: Thu, 22 Mar 2018 08:18:27 +0100 Subject: [PATCH] fix #4159 --- gui/qt/main_window.py | 12 ++++++++++-- lib/simple_config.py | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 90c21e636..f16ad1d2d 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -396,7 +396,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): self.show_warning(msg, title=_('Information')) def open_wallet(self): - wallet_folder = self.get_wallet_folder() + try: + wallet_folder = self.get_wallet_folder() + except FileNotFoundError as e: + self.show_error(str(e)) + return filename, __ = QFileDialog.getOpenFileName(self, "Select your wallet file", wallet_folder) if not filename: return @@ -440,7 +444,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): return os.path.dirname(os.path.abspath(self.config.get_wallet_path())) def new_wallet(self): - wallet_folder = self.get_wallet_folder() + try: + wallet_folder = self.get_wallet_folder() + except FileNotFoundError as e: + self.show_error(str(e)) + return i = 1 while True: filename = "wallet_%d" % i diff --git a/lib/simple_config.py b/lib/simple_config.py index de8fffae4..d78ffb67e 100644 --- a/lib/simple_config.py +++ b/lib/simple_config.py @@ -233,6 +233,10 @@ class SimpleConfig(PrintError): return path # default path + if not os.path.exists(self.path): + raise FileNotFoundError( + _('Electrum datadir does not exist. Was it deleted while running?') + '\n' + + _('Should be at {}').format(self.path)) dirpath = os.path.join(self.path, "wallets") if not os.path.exists(dirpath): if os.path.islink(dirpath):