Refactored user_dir to utils and replaced it in wallet and config
This commit is contained in:
parent
fbf854bcb8
commit
6da25727f8
1
electrum
1
electrum
|
@ -150,7 +150,6 @@ if __name__ == '__main__':
|
|||
except ImportError:
|
||||
import electrum.gui_qt as gui
|
||||
elif options.gui == 'lite':
|
||||
print 'ohhai'
|
||||
# Let's do some dep checking and handle missing ones gracefully
|
||||
try:
|
||||
from PyQt4.QtCore import *
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import json
|
||||
import os
|
||||
from lib.util import user_dir
|
||||
|
||||
class SimpleConfig:
|
||||
default_options = {"gui": "lite"}
|
||||
|
@ -27,15 +28,7 @@ class SimpleConfig:
|
|||
|
||||
def __init__(self):
|
||||
# Find electrum data folder
|
||||
if "HOME" in os.environ:
|
||||
self.config_folder = os.path.join(os.environ["HOME"], ".electrum")
|
||||
elif "LOCALAPPDATA" in os.environ:
|
||||
self.config_folder = os.path.join(os.environ["LOCALAPPDATA"], "Electrum")
|
||||
elif "APPDATA" in os.environ:
|
||||
self.config_folder = os.path.join(os.environ["APPDATA"], "Electrum")
|
||||
else:
|
||||
raise BaseException("No home directory found in environment variables.")
|
||||
|
||||
self.config_folder = user_dir()
|
||||
# Read the file
|
||||
if os.path.exists(self.config_file_path()):
|
||||
self.load_config()
|
||||
|
|
10
lib/util.py
10
lib/util.py
|
@ -8,6 +8,16 @@ def print_error(*args):
|
|||
sys.stderr.write(" ".join(args) + "\n")
|
||||
sys.stderr.flush()
|
||||
|
||||
def user_dir():
|
||||
if "HOME" in os.environ:
|
||||
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:
|
||||
return os.path.join(os.environ["APPDATA"], "Electrum")
|
||||
else:
|
||||
raise BaseException("No home directory found in environment variables.")
|
||||
|
||||
def appdata_dir():
|
||||
"""Find the path to the application data directory; add an electrum folder and return path."""
|
||||
if platform.system() == "Windows":
|
||||
|
|
|
@ -32,6 +32,7 @@ import ecdsa
|
|||
|
||||
from ecdsa.util import string_to_number, number_to_string
|
||||
from util import print_error
|
||||
from util import user_dir
|
||||
|
||||
############ functions from pywallet #####################
|
||||
|
||||
|
@ -365,14 +366,8 @@ class Wallet:
|
|||
return
|
||||
# Look for wallet file in the default data directory.
|
||||
# Keeps backwards compatibility.
|
||||
if "HOME" in os.environ:
|
||||
wallet_dir = os.path.join(os.environ["HOME"], ".electrum")
|
||||
elif "LOCALAPPDATA" in os.environ:
|
||||
wallet_dir = os.path.join(os.environ["LOCALAPPDATA"], "Electrum")
|
||||
elif "APPDATA" in os.environ:
|
||||
wallet_dir = os.path.join(os.environ["APPDATA"], "Electrum")
|
||||
else:
|
||||
raise BaseException("No home directory found in environment variables.")
|
||||
wallet_dir = user_dir()
|
||||
|
||||
# Make wallet directory if it does not yet exist.
|
||||
if not os.path.exists(wallet_dir):
|
||||
os.mkdir(wallet_dir)
|
||||
|
|
Loading…
Reference in New Issue