def backup_wallet(self): try: folderName = QFileDialog.getExistingDirectory(QWidget(), _('Select folder to save a copy of your wallet to'), os.path.expanduser('~/')) if folderName: sourceFile = util.user_dir() + '/electrum.dat' 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: QMessageBox.critical(None,"Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location.")+"\n" + str(reason))
def write_schedule_file(schedule_dict): schedule_path = os.path.join(user_dir(), 'schedule') s = json.dumps(schedule_dict, indent=4, sort_keys=True) try: with open(schedule_path, "w", encoding='utf-8') as f: f.write(s) os.chmod(schedule_path, stat.S_IREAD | stat.S_IWRITE) except FileNotFoundError: if os.path.exists(schedule_path): raise
def read_schedule_file(): schedule_path = os.path.join(user_dir(), 'schedule') if not os.path.exists(schedule_path): return {} try: with open(schedule_path, "r", encoding='utf-8') as f: data = f.read() result = json.loads(data) except: return {} if not type(result) is dict: return {} return result
def backup_wallet(self): try: folderName = QFileDialog.getExistingDirectory( QWidget(), _('Select folder to save a copy of your wallet to'), os.path.expanduser('~/')) if folderName: sourceFile = util.user_dir() + '/electrum.dat' 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: QMessageBox.critical( None, "Unable to create backup", _("Electrum was unable to copy your wallet file to the specified location." ) + "\n" + str(reason))
def token_path(): dir = user_dir() + '/coinbase_buyback' if not os.access(dir, os.F_OK): os.mkdir(dir) return dir + '/token'