from ConfigParser import SafeConfigParser _loaded = False class phantom(): def __init__(self): pass def load(): if _loaded: return global database, maxfail, search, torhosts, watchd_threads, checktime, timeout, read_timeout, submit_after, use_ssl, url_checktime, url_perfail_checktime ## read the config files parser = SafeConfigParser() parser.read('config.ini') database = parser.get('global', 'database') #maxfail = parser.getint('global', 'proxy_max_fail') torhosts = [ str(i).strip() for i in parser.get('global', 'tor_host').split(',') ] global _watchd _watchd = phantom() _watchd.threads = parser.getint('watcherd', 'threads') _watchd.timeout = parser.getint('watcherd', 'timeout') _watchd.submit_after = parser.getint('watcherd', 'submit_after') _watchd.use_ssl = parser.getboolean('watcherd', 'use_ssl') _watchd.debug = parser.getboolean('watcherd', 'debug') _watchd.maxfail = parser.getint('watcherd', 'max_fail') global _leechd _leechd = phantom() _leechd.checktime = parser.get('proxyfind', 'checktime') _leechd.perfail_checktime = parser.get('proxyfind', 'perfail_checktime') _leechd.search = parser.getboolean('proxyfind', 'search') global watchd_debug watchd_debug = parser.getboolean('watcherd', 'debug') # allow overriding select items from the commandline import argparse aparse = argparse.ArgumentParser() aparse.add_argument('--watchd_threads', help="how many proxy checker threads to spin up, 0==none, default: 10", type=int, default=_watchd.threads, required=False) args = aparse.parse_args() _watchd.threads = args.watchd_threads global servers with open('servers.txt', 'r') as handle: servers = [x.strip() for x in handle.readlines() if len(x.strip()) > 0]