URI: 
       tencapsulate parse_proxy_options - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit d0c8a4827495da511a2c224b6bf58036f54687c9
   DIR parent f0556bb0d342a4bbc7ffc9a817714715e60757ea
  HTML Author: ThomasV <thomasv@gitorious>
       Date:   Thu, 11 Oct 2012 21:37:02 +0200
       
       encapsulate parse_proxy_options
       
       Diffstat:
         M lib/interface.py                    |      37 +++++++++++++++++--------------
         M lib/simple_config.py                |       6 ++----
       
       2 files changed, 22 insertions(+), 21 deletions(-)
       ---
   DIR diff --git a/lib/interface.py b/lib/interface.py
       t@@ -35,22 +35,6 @@ def pick_random_server():
            return random.choice( DEFAULT_SERVERS )
        
        
       -def parse_proxy_options(s):
       -    if s.lower() == 'none': return None
       -    proxy = { "mode":"socks5", "host":"localhost" }
       -    args = s.split(':')
       -    n = 0
       -    if proxy_modes.count(args[n]) == 1:
       -        proxy["mode"] = args[n]
       -        n += 1
       -    if len(args) > n:
       -        proxy["host"] = args[n]
       -        n += 1
       -    if len(args) > n:
       -        proxy["port"] = args[n]
       -    else:
       -        proxy["port"] = "8080" if proxy["mode"] == "http" else "1080"
       -    return proxy
        
        
        
       t@@ -324,7 +308,7 @@ class Interface(TcpStratumInterface, HttpStratumInterface):
                    host, port, protocol = s.split(':')
                    port = int(port)
        
       -        proxy = config.get('proxy')
       +        proxy = self.parse_proxy_options(config.get('proxy','none'))
                self.server = host + ':%d:%s'%(port, protocol)
        
                #print protocol, host, port
       t@@ -337,6 +321,25 @@ class Interface(TcpStratumInterface, HttpStratumInterface):
                    TcpStratumInterface.__init__(self, host, port, proxy)
        
        
       +    def parse_proxy_options(self, s):
       +        if type(s) != type(""): return None  
       +        if s.lower() == 'none': return None
       +        proxy = { "mode":"socks5", "host":"localhost" }
       +        args = s.split(':')
       +        n = 0
       +        if proxy_modes.count(args[n]) == 1:
       +            proxy["mode"] = args[n]
       +            n += 1
       +        if len(args) > n:
       +            proxy["host"] = args[n]
       +            n += 1
       +        if len(args) > n:
       +            proxy["port"] = args[n]
       +        else:
       +            proxy["port"] = "8080" if proxy["mode"] == "http" else "1080"
       +        return proxy
       +
       +
            def set_server(self, server, proxy=None):
                # raise an error if the format isnt correct
                a,b,c = server.split(':')
   DIR diff --git a/lib/simple_config.py b/lib/simple_config.py
       t@@ -3,7 +3,6 @@ import os, ast
        from util import user_dir
        
        from version import ELECTRUM_VERSION, SEED_VERSION
       -from interface import parse_proxy_options
        
        
        # old stuff.. should be removed at some point
       t@@ -40,7 +39,7 @@ class SimpleConfig:
                self.options_config = {}
        
                if options.server: self.options_config['server'] = options.server
       -        if options.proxy: self.options_config['proxy'] = parse_proxy_options(options.proxy)
       +        if options.proxy: self.options_config['proxy'] = options.proxy
                if options.gui: self.options_config['gui'] = options.gui
                
                
       t@@ -92,7 +91,6 @@ class SimpleConfig:
            def read_common_config(self):
                for name in [ os.path.join( user_dir(), 'electrum.conf') , '/etc/electrum.conf']:
                    if os.path.exists(name):
       -                from interface import parse_proxy_options
                        try:
                            import ConfigParser
                        except:
       t@@ -106,7 +104,7 @@ class SimpleConfig:
                        except:
                            pass
                        try:
       -                    self.common_config['proxy'] = parse_proxy_options(p.get('client','proxy'))
       +                    self.common_config['proxy'] = p.get('client','proxy')
                        except:
                            pass
                        try: