Changeset 142:814d4a3c6ca0

Show
Ignore:
Timestamp:
11/09/08 03:04:44 (3 years ago)
Author:
chris
Branch:
unix
Message:

Added support for using a proxy to get files from weather.gov. In the [main] section a keyword called 'proxy' can be used. The form should be ' http://proxy.example.com:3128' for example.

Files:
5 modified

Legend:

Unmodified
Added
Removed
  • .todo

    r141 r142  
    2727        create script to ram all the code into a single file to make it more like the original program 
    2828    </note> 
    29     <note priority="medium" time="1226198990"> 
     29    <note priority="medium" time="1226198990" done="1226199792"> 
    3030        allow use of a proxy to fetch the xml files 
     31        <comment> 
     32            Added support, new config in [main] section called 'proxy' 
     33        </comment> 
    3134    </note> 
    3235</todo> 
  • StormSiren/StormConfig.py

    r122 r142  
    6565                self.log               = logging.getLogger('StormConfig') 
    6666                self.__max_history     = History.DEFAULT_MAX_HISTORICAL_EVENTS 
     67                self.__proxy           = '' 
    6768 
    6869                super(StormConfig,self).__init__(__APPNAME__,config_file, log_config_file) 
     
    8586 
    8687                xstates = self.getRequired('main','states') 
    87                 if xstates: 
     88                if(xstates): 
    8889                         self.__states = string.split(xstates, ',') 
     90 
     91                self.__proxy = self.get('main','proxy', None) 
    8992 
    9093                num_watchers = self.getRequired('main','watchers') 
     
    174177                str += "\n\t".join(self.__states) 
    175178 
     179                str += "\nProxy: %i\n" % self.__proxy 
    176180                str += "\nHistory: %i\n" % self.max_history 
    177181                str += "\nDevices: %i\n" % len(self.devices) 
     
    219223                return self.__max_history 
    220224 
     225        def getProxy(self): 
     226                return self.__proxy 
     227 
    221228        debug = property(getDebug,None,None) 
    222229        max_history = property(getMaxHistory,None,None) 
     230        proxy = property(getProxy,None,None) 
  • StormSiren/StormWeather.py

    r122 r142  
    5151 
    5252class StormWeather(XmlWeather): 
    53         def __init__(self, state, history, simfetch = False, simalert = False): 
    54                 super(StormWeather,self).__init__(state,history,simfetch) 
     53        def __init__(self, state, history, simfetch = False, simalert = False, proxy = None): 
     54                super(StormWeather,self).__init__(state,history,simfetch,proxy) 
    5555                self.log = logging.getLogger("StormWeather") 
    5656                self.__alert_devs = [] 
  • StormSiren/XmlWeather.py

    r122 r142  
    5151 
    5252class XmlWeather(object): 
    53         def __init__(self, state, history, simfetch = False): 
     53        def __init__(self, state, history, simfetch = False, proxy = None): 
    5454                super(XmlWeather,self).__init__() 
    5555                self.__data       = '' 
     
    6262                self.__history    = history 
    6363                self.__simfetch   = simfetch 
     64                self.__proxy      = proxy 
    6465                self.log = logging.getLogger("XmlWeather") 
    6566 
     
    7879                                self.__dom = minidom.parse("examples/" + self.__state.lower() + ".cap") 
    7980                        else: 
    80                                 self.__dom = minidom.parse(urllib.urlopen(self.__url)) 
     81                                proxy = None 
     82                                if(self.__proxy): 
     83                                        self.log.info("Using proxy: %s" % self.__proxy) 
     84                                        proxy = { 'http' : self.__proxy } 
     85                                self.__dom = minidom.parse(urllib.urlopen(self.__url, proxies = proxy)) 
    8186                except IOError,e: 
    8287                        # No net connection available, exit. 
  • siren

    r135 r142  
    115115                for state in conf.states: 
    116116                        log.info("State: " + state) 
    117                         xw = StormWeather(state,history,options.simfetch,options.simalert) 
     117                        xw = StormWeather(state,history,options.simfetch,options.simalert,conf.proxy) 
    118118                        #xw.display() 
    119119                        for dev in conf.devices: