electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit fd13d19cb86eded4e386ea127a76c9736c150219
parent 6bf18d8607f78f02be63eebffcfada50248f3e97
Author: thomasv <thomasv@gitorious>
Date:   Tue,  9 Oct 2012 15:48:06 +0200

fix proxy issues: override config with command line option, and use interface.proxy in gui

Diffstat:
Melectrum | 6++----
Mlib/gui_qt.py | 21++++++++++++---------
Mlib/simple_config.py | 9+++++++--
3 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/electrum b/electrum @@ -118,9 +118,7 @@ if __name__ == '__main__': parser.add_option("-p", "--proxy", dest="proxy", default=None, help="set proxy [type:]host[:port], where type is socks4,socks5 or http") options, args = parser.parse_args() - if options.proxy: - options.proxy = parse_proxy_options(options.proxy) - + proxy = parse_proxy_options(options.proxy) if options.proxy else simple_config.config["proxy"] wallet = Wallet() wallet.set_path(options.wallet_path) wallet.read() @@ -180,7 +178,7 @@ if __name__ == '__main__': sys.exit("Error: Unknown GUI: " + options.gui) gui = gui.ElectrumGui(wallet) - interface = WalletSynchronizer(wallet, True, gui.server_list_changed, options.proxy) + interface = WalletSynchronizer(wallet, True, gui.server_list_changed, proxy) interface.start() try: diff --git a/lib/gui_qt.py b/lib/gui_qt.py @@ -1406,11 +1406,11 @@ class ElectrumWindow(QMainWindow): proxy_port.setFixedWidth(50) proxy_mode.addItems(['NONE', 'SOCKS4', 'SOCKS5', 'HTTP']) - cfg = SimpleConfig() - proxy_config = cfg.config['proxy'] - proxy_mode.setCurrentIndex(proxy_mode.findText(str(proxy_config["mode"]).upper())) - proxy_host.setText(proxy_config["host"]) - proxy_port.setText(proxy_config["port"]) + proxy_config = interface.proxy if interface.proxy else { "mode":"none", "host":"localhost", "port":"8080"} + proxy_mode.setCurrentIndex(proxy_mode.findText(str(proxy_config.get("mode").upper()))) + proxy_host.setText(proxy_config.get("host")) + proxy_port.setText(proxy_config.get("port")) + hbox.addWidget(QLabel(_('Proxy') + ':')) hbox.addWidget(proxy_mode) hbox.addWidget(proxy_host) @@ -1451,11 +1451,14 @@ class ElectrumWindow(QMainWindow): server = unicode( host_line.text() ) try: - cfg.set_key("proxy", { u'mode':unicode(proxy_mode.currentText()).lower(), u'host':unicode(proxy_host.text()), u'port':unicode(proxy_port.text()) }, True) - if cfg.config["proxy"]["mode"] != "none": - wallet.set_server(server, cfg.config["proxy"]) + if proxy_mode.currentText() != 'NONE': + proxy = { u'mode':unicode(proxy_mode.currentText()).lower(), u'host':unicode(proxy_host.text()), u'port':unicode(proxy_port.text()) } else: - wallet.set_server(server) + proxy = None + + cfg = SimpleConfig() + cfg.set_key("proxy", proxy, True) + wallet.set_server(server, proxy) except Exception as err: QMessageBox.information(None, _('Error'), str(err), _('OK')) diff --git a/lib/simple_config.py b/lib/simple_config.py @@ -5,8 +5,13 @@ from util import user_dir class SimpleConfig: - default_options = {"gui": "lite", "proxy": { "mode": "none", "host":"localhost", "port":"8080" }, - "winpos-qt": [100, 100, 840, 400], "winpos-lite": [4, 25, 351, 149], "history": False } + default_options = { + "gui": "lite", + "proxy": None, + "winpos-qt": [100, 100, 840, 400], + "winpos-lite": [4, 25, 351, 149], + "history": False + } def __init__(self): # Find electrum data folder