def _get_fp(self, cfg_file): log.debug("Loading file: %s" % cfg_file) if os.path.exists(cfg_file): if not os.path.isfile(cfg_file): raise exception.ConfigError( 'config %s exists but is not a regular file' % cfg_file) else: raise self.exception_class(cfg_file,self) return open(cfg_file)
def _get_urlfp(self, url): log.debug("Loading url: %s" % url) try: fp = urllib.urlopen(url) if fp.getcode() == 404: raise exception.ConfigError("url %s does not exist" % url) fp.name = url return fp except IOError, e: raise exception.ConfigError( "error loading config from url %s\n%s" % (url, e))
def _load_defaults(self, settings, store): """ Sets the default for each setting in settings regardless of whether the setting was specified in the config or not. """ section_conf = store for setting in settings: default = settings[setting][2] if section_conf.get(setting) is None: if DEBUG_CONFIG: log.debug('%s setting not specified. Defaulting to %s' % \ (setting, default)) section_conf[setting] = default
def load(self): """ Populate this config object from the StarFlow config files """ log.debug('Loading config') store = self._load_section('local_systemwide', {}) self.name = store['name'] self.system_mode = store['system_mode'] self.protection = store['protection'] self.gmail_account_name = store["gmail_account_name"] self.gmail_account_passwd = store["gmail_account_passwd"] self._generated_code_dir = os.path.join(self._root_dir,store["generated_code_dir"]) self.load_live_module_filters() return self
sc.execute(args) except exception.BaseException,e: lines = e.msg.splitlines() for l in lines: log.error(l) #log.error(e.msg) sys.exit(1) except socket.gaierror,e: log.error("Unable to connect: %s" % e) log.error("Check your internet connection?") sys.exit(1) except Exception,e: import traceback if not gopts.DEBUG: traceback.print_exc() log.debug(traceback.format_exc()) print log.error("Oops! Looks like you've found a bug in StarFlow") log.error("Debug file written to: %s" % static.DEBUG_FILE) log.error("Please submit this file, minus any private information,") log.error("to [email protected]") sys.exit(1) def test(): pass def main(): StarFlowCLI().main() if os.environ.has_key('starflow_commands_test'):
sc.execute(args) except exception.BaseException, e: lines = e.msg.splitlines() for l in lines: log.error(l) #log.error(e.msg) sys.exit(1) except socket.gaierror, e: log.error("Unable to connect: %s" % e) log.error("Check your internet connection?") sys.exit(1) except Exception, e: import traceback if not gopts.DEBUG: traceback.print_exc() log.debug(traceback.format_exc()) print log.error("Oops! Looks like you've found a bug in StarFlow") log.error("Debug file written to: %s" % static.DEBUG_FILE) log.error( "Please submit this file, minus any private information,") log.error("to [email protected]") sys.exit(1) def test(): pass def main(): StarFlowCLI().main()