from lib import Wallet, WalletSynchronizer, format_satoshis, mnemonic, prompt_password
except ImportError:
from electrum import Wallet, WalletSynchronizer, format_satoshis, mnemonic, prompt_password
-
+
from decimal import Decimal
+from lib import SimpleConfig
known_commands = {
'help':'Prints this help',
if __name__ == '__main__':
+ # Load simple config class
+ simple_config = SimpleConfig()
+
usage = "usage: %prog [options] command\nCommands: "+ (', '.join(known_commands))
parser = optparse.OptionParser(prog=usage)
- parser.add_option("-g", "--gui", dest="gui", default="lite", help="gui")
+ parser.add_option("-g", "--gui", dest="gui", default=simple_config.config["gui"], help="gui")
parser.add_option("-w", "--wallet", dest="wallet_path", help="wallet path (default: electrum.dat)")
parser.add_option("-o", "--offline", action="store_true", dest="offline", default=False, help="remain offline")
parser.add_option("-a", "--all", action="store_true", dest="show_all", default=False, help="show all addresses")
parser.add_option("-r", "--remote", dest="remote_url", default=None, help="URL of a remote wallet")
options, args = parser.parse_args()
+
wallet = Wallet()
wallet.set_path(options.wallet_path)
wallet.read()
error_message = QErrorMessage()
error_message.setFixedSize(350,200)
error_message.showMessage("<p>Sorry, the Electrum 'Lite GUI' requires Qt >= 4.7 to run. The pro GUI will be started instead.</p><p>Check your distributions packages for upgrades.</p>")
+ simple_config.config["gui"] = "qt"
+ simple_config.save_config
app.exec_()
try:
--- /dev/null
+import json
+import os
+
+class SimpleConfig:
+ default_options = {"gui": "lite"}
+
+ def save_config(self):
+ f = open(self.config_file_path(), "w+")
+ f.write(json.dumps(self.config))
+
+ def load_config(self):
+ f = open(self.config_file_path(), "r")
+ file_contents = f.read()
+ if file_contents:
+ self.config = json.loads(file_contents)
+ else:
+ self.config = self.default_options
+ self.save_config()
+
+ def config_file_path(self):
+ return "%s" % (self.config_folder + "/config.json")
+
+ 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.")
+
+ # Read the file
+ if os.path.exists(self.config_file_path()):
+ self.load_config()
+ else:
+ self.config = self.default_options
+ self.save_config()
+