From c1fabb33321df38341fa04bccd38854ebc97b129 Mon Sep 17 00:00:00 2001 From: thomasv Date: Thu, 1 Aug 2013 14:58:30 +0200 Subject: [PATCH] fix backup_wallet --- gui/gui_classic.py | 2 +- gui/qt_util.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gui/gui_classic.py b/gui/gui_classic.py index aeca751e4..389911800 100644 --- a/gui/gui_classic.py +++ b/gui/gui_classic.py @@ -386,7 +386,7 @@ class ElectrumWindow(QMainWindow): wallet_menu = menubar.addMenu(_("&Wallet")) wallet_backup = wallet_menu.addAction(_("&Create backup")) - wallet_backup.triggered.connect(backup_wallet) + wallet_backup.triggered.connect(lambda: backup_wallet(self.config.path)) show_menu = wallet_menu.addMenu(_("Show")) diff --git a/gui/qt_util.py b/gui/qt_util.py index f43f47fe8..56d4845d9 100644 --- a/gui/qt_util.py +++ b/gui/qt_util.py @@ -3,16 +3,16 @@ from PyQt4.QtGui import * from PyQt4.QtCore import * import os.path -def backup_wallet(): +def backup_wallet(path): + import shutil + directory, fileName = os.path.split(path) try: - folderName = QFileDialog.getExistingDirectory(QWidget(), _('Select folder to save a copy of your wallet to'), os.path.expanduser('~/')) - if folderName: - # TODO: Can we get the current wallet file instead of bruteforcing the default one? - sourceFile = self.wallet.config.path - shutil.copy2(sourceFile, str(folderName)) - QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(folderName)) + otherpath = unicode( QFileDialog.getOpenFileName(QWidget(), _('Enter a filename for the copy of your wallet'), directory) ) + if otherpath and path!=otherpath: + shutil.copy2(path, otherpath) + QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(otherpath)) except (IOError, os.error), reason: - QMessageBox.critical(None,"Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location.")+"\n" + str(reason)) + QMessageBox.critical(None,"Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location.")+"\n" + str(reason)) def ok_cancel_buttons(dialog, ok_label=_("OK") ): hbox = QHBoxLayout()