Added migration to APPDATA from LOCALAPPDATA for windows based Electrum installations

This commit is contained in:
Maran 2013-02-18 23:29:19 +01:00
parent 63cce2174f
commit 1b2a319f18
4 changed files with 28 additions and 5 deletions

View File

@ -9,6 +9,9 @@ older versions of Electrum.
and Blockchain functions can be accessed through it. The goal is to and Blockchain functions can be accessed through it. The goal is to
let users extend Electrum through custom scripts. let users extend Electrum through custom scripts.
* The location of the Electrum folder in Windows changed from LOCALAPPDATA
to APPDATA. Discussion on this topic can be found here: https://bitcointalk.org/index.php?topic=144575.0
* New menu item to display the private key corresponding to a * New menu item to display the private key corresponding to a
receiving address. receiving address.

View File

@ -19,6 +19,7 @@
import re import re
import sys, os, time import sys, os, time
import optparse import optparse
import platform
try: try:
import ecdsa import ecdsa
@ -157,6 +158,11 @@ if __name__ == '__main__':
for k, v in config_options.items(): for k, v in config_options.items():
if v is None: config_options.pop(k) if v is None: config_options.pop(k)
# Wallet migration on Electrum 1.7
# Todo: In time we could remove this again
if platform.system() == "Windows":
util.check_windows_wallet_migration()
config = SimpleConfig(config_options) config = SimpleConfig(config_options)
wallet = Wallet(config) wallet = Wallet(config)
@ -174,6 +180,7 @@ if __name__ == '__main__':
#right GUI toolkit based the GUI command line option given #right GUI toolkit based the GUI command line option given
if cmd == 'gui': if cmd == 'gui':
pref_gui = config.get('gui','classic') pref_gui = config.get('gui','classic')
if pref_gui == 'gtk': if pref_gui == 'gtk':
try: try:
import lib.gui as gui import lib.gui as gui

View File

@ -11,9 +11,6 @@ except ImportError:
print "If you have pip installed try 'sudo pip install pyqt' if you are on Debian/Ubuntu try 'sudo apt-get install python-qt4'." print "If you have pip installed try 'sudo pip install pyqt' if you are on Debian/Ubuntu try 'sudo apt-get install python-qt4'."
sys.exit(0) sys.exit(0)
from decimal import Decimal as D from decimal import Decimal as D
from util import get_resource_path as rsrc from util import get_resource_path as rsrc
from i18n import _ from i18n import _

View File

@ -1,5 +1,6 @@
import os, sys import os, sys
import platform import platform
import shutil
from datetime import datetime from datetime import datetime
is_verbose = True is_verbose = True
@ -68,14 +69,29 @@ def print_msg(*args):
sys.stdout.write(" ".join(args) + "\n") sys.stdout.write(" ".join(args) + "\n")
sys.stdout.flush() sys.stdout.flush()
def check_windows_wallet_migration():
from PyQt4.QtGui import *
from i18n import _
app = QApplication(sys.argv)
if os.path.exists(os.path.join(os.environ["LOCALAPPDATA"], "Electrum")):
if os.path.exists(os.path.join(os.environ["APPDATA"], "Electrum")):
QMessageBox.information(None,_("Folder migration"), _("Two Electrum folders have been found, the default Electrum location for Windows has changed from %s to %s since Electrum 1.7, please check your wallets and fix the problem manually." % (os.environ["LOCALAPPDATA"], os.environ["APPDATA"])))
sys.exit()
QMessageBox.information(None, _("Folder migration"), _("This version of Electrum moved the Electrum folder on windows from %s to %s, your Electrum folder will now be moved.") % (os.environ["LOCALAPPDATA"], os.environ["APPDATA"]))
shutil.move(os.path.join(os.environ["LOCALAPPDATA"], "Electrum"), os.path.join(os.environ["APPDATA"], "Electrum"))
QMessageBox.information(None,_("Migration status"), _("Your wallet has been moved sucessfully."))
def user_dir(): def user_dir():
if "HOME" in os.environ: if "HOME" in os.environ:
return os.path.join(os.environ["HOME"], ".electrum") return os.path.join(os.environ["HOME"], ".electrum")
elif "LOCALAPPDATA" in os.environ:
return os.path.join(os.environ["LOCALAPPDATA"], "Electrum")
elif "APPDATA" in os.environ: elif "APPDATA" in os.environ:
return os.path.join(os.environ["APPDATA"], "Electrum") return os.path.join(os.environ["APPDATA"], "Electrum")
elif "LOCALAPPDATA" in os.environ:
return os.path.join(os.environ["LOCALAPPDATA"], "Electrum")
else: else:
#raise BaseException("No home directory found in environment variables.") #raise BaseException("No home directory found in environment variables.")
return return