fix backup_wallet
This commit is contained in:
@@ -386,7 +386,7 @@ class ElectrumWindow(QMainWindow):
|
|||||||
|
|
||||||
wallet_menu = menubar.addMenu(_("&Wallet"))
|
wallet_menu = menubar.addMenu(_("&Wallet"))
|
||||||
wallet_backup = wallet_menu.addAction(_("&Create backup"))
|
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"))
|
show_menu = wallet_menu.addMenu(_("Show"))
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ from PyQt4.QtGui import *
|
|||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
import os.path
|
import os.path
|
||||||
|
|
||||||
def backup_wallet():
|
def backup_wallet(path):
|
||||||
|
import shutil
|
||||||
|
directory, fileName = os.path.split(path)
|
||||||
try:
|
try:
|
||||||
folderName = QFileDialog.getExistingDirectory(QWidget(), _('Select folder to save a copy of your wallet to'), os.path.expanduser('~/'))
|
otherpath = unicode( QFileDialog.getOpenFileName(QWidget(), _('Enter a filename for the copy of your wallet'), directory) )
|
||||||
if folderName:
|
if otherpath and path!=otherpath:
|
||||||
# TODO: Can we get the current wallet file instead of bruteforcing the default one?
|
shutil.copy2(path, otherpath)
|
||||||
sourceFile = self.wallet.config.path
|
QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(otherpath))
|
||||||
shutil.copy2(sourceFile, str(folderName))
|
|
||||||
QMessageBox.information(None,"Wallet backup created", _("A copy of your wallet file was created in")+" '%s'" % str(folderName))
|
|
||||||
except (IOError, os.error), reason:
|
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") ):
|
def ok_cancel_buttons(dialog, ok_label=_("OK") ):
|
||||||
hbox = QHBoxLayout()
|
hbox = QHBoxLayout()
|
||||||
|
|||||||
Reference in New Issue
Block a user