def parseConfFile(self): if not self.conf.has_section('sources'): self.conf.add_section('sources') configInfo = {} for c in Source.__subclasses__(): configInfo[c.getSourceName()] = c.getConfig(self.conf, "sources") if not self.conf.has_section('globals'): self.conf.add_section('globals') configInfo['globals'] = c.getConfig(self.conf, "globals") return configInfo
def __init__(self, configFile=False): home = os.path.dirname(sys.argv[0]) if (not configFile): configFile = "checkhosts.conf" self.files = [ os.path.join(home, configFile), "/etc/checkhosts.conf", os.path.join(os.getenv("HOME"), ".checkhosts.conf") ] self.defaults = {} for c in Source.__subclasses__(): self.mergeDefaults(c.getConfigDefaults()) self.conf = ConfigParser.SafeConfigParser(self.defaults) self.conf.read(self.files) self.conf.options = self.parseConfFile()
def __init__(self, configFile=False): home = os.path.dirname(sys.argv[0]) if (not configFile): configFile = "checkhosts.conf" self.files = [ os.path.join(home, configFile), "/etc/checkhosts.conf", os.path.join(os.getenv("HOME"), ".checkhosts.conf")] self.defaults = {} for c in Source.__subclasses__(): self.mergeDefaults(c.getConfigDefaults()) self.conf = ConfigParser.SafeConfigParser(self.defaults) self.conf.read(self.files) self.conf.options = self.parseConfFile()
def __init__(self, hostOpts, hostExprs, timeout, verbose): self.sources = {} self.filteredHosts = {} self.hostOpts = hostOpts if hostExprs and ',' in hostExprs: self.hostExprs = [h.strip() for h in hostExprs.split(',')] elif hostExprs: self.hostExprs = [hostExprs] else: self.hostExprs = None self.timeout = timeout self.verbose = verbose self.sourcesClasses = {} for c in Source.__subclasses__(): self.sourcesClasses[c.getSourceName()] = c self.filters = None
configfile = val elif opt in ["-t", "--timeout"]: if not val.isdigit(): HHelp.usage("Timeout option requires a positive integer") timeout = int(val) elif opt in ["-v", "--verbose"]: verbose = 1 elif opt in ["--debug"]: verbose = 2 elif opt in ["-V", "--version"]: print "check-hosts.py %s" % version sys.exit(0) elif opt in ["-h", "--help"]: HHelp.usage("Help message") elif opt in ["-e", "--extendedhelp"]: HHelp.extendedUsage(Source.getKnownSources()) else: HHelp.usage("Unknown option specified: %s" % opt) if len(remainder) > 0: HHelp.usage("Unknown option specified: <%s>" % remainder[0]) mainOptsSet = 0 for opt in [filterExpr, cli, reportArg]: if opt: mainOptsSet += 1 if not mainOptsSet: HHelp.usage("You must choose one of 'filter', 'report' or 'cli'") if mainOptsSet > 1: HHelp.usage("You may choose only one of 'filter', 'report' or 'cli'")