示例#1
0
文件: Main.py 项目: aagbsn/bridgedb
def run():
    """Parse the command line to determine where the configuration is.
       Parse the configuration, and start the servers.
    """
    options, arguments = Opt.parseOpts()
    configuration = {}

    if options.testing:
        configuration = CONFIG
    elif not options.configfile:
        print "Syntax: %s -c CONFIGFILE" % sys.argv[0]
        sys.exit(1)
    else:
        configFile = options.configfile
        execfile(configFile, configuration)
        C = Conf(**configuration)
        configuration = C

    # Change to the directory where we're supposed to run.
    if configuration.RUN_IN_DIR:
        os.chdir(os.path.expanduser(configuration.RUN_IN_DIR))

    if options.dumpbridges:
        bucketManager = Bucket.BucketManager(configuration)
        bucketManager.assignBridgesToBuckets()
        bucketManager.dumpBridges()
    else:
        startup(configuration)
示例#2
0
def run():
    """Parse the command line to determine where the configuration is.
       Parse the configuration, and start the servers.
    """
    options, arguments = Opt.parseOpts()
    configuration = {}

    if options.testing:
        configuration = CONFIG
    elif not options.configfile:
        print "Syntax: %s -c CONFIGFILE" % sys.argv[0]
        sys.exit(1)
    else:
        configFile = options.configfile
        execfile(configFile, configuration)
        C = Conf(**configuration)
        configuration = C

    # Change to the directory where we're supposed to run.
    if configuration.RUN_IN_DIR:
        os.chdir(os.path.expanduser(configuration.RUN_IN_DIR))

    if options.dumpbridges:
        bucketManager = Bucket.BucketManager(configuration)
        bucketManager.assignBridgesToBuckets()
        bucketManager.dumpBridges()
    else:
        startup(configuration)
示例#3
0
    def reload():
        logging.info("Caught SIGHUP")

        # re open config file
        options, arguments = Opt.parseOpts()
        configuration = {}
        if options.configfile:
            execfile(options.configfile, configuration)
            cfg = Conf(**configuration)
            # update loglevel on (re)load
            level = getattr(cfg, 'LOGLEVEL', 'WARNING')
            level = getattr(logging, level)
            logging.getLogger().setLevel(level)

        load(cfg, splitter, clear=True)
        proxyList.replaceProxyList(loadProxyList(cfg))
        logging.info("%d bridges loaded", len(splitter))
        if emailDistributor:
            emailDistributor.prepopulateRings()  # create default rings
            logging.info("%d for email", len(emailDistributor.splitter))
        if ipDistributor:
            ipDistributor.prepopulateRings()  # create default rings
            logging.info("%d for web:", len(ipDistributor.splitter))
            for (n, (f, r)) in ipDistributor.splitter.filterRings.items():
                logging.info(" by filter set %s, %d" % (n, len(r)))
            #logging.info("  by location set: %s",
            #             " ".join(str(len(r)) for r in ipDistributor.rings))
            #logging.info("  by category set: %s",
            #             " ".join(str(len(r)) for r in ipDistributor.categoryRings))
            #logging.info("Here are all known bridges in the category section:")
            #for r in ipDistributor.categoryRings:
            #    for name, b in r.bridges.items():
            #        logging.info("%s" % b.getConfigLine(True))

        # Dump bridge pool assignments to disk.
        try:
            logging.debug("Dumping pool assignments file")
            f = open(cfg.ASSIGNMENTS_FILE, 'a')
            f.write("bridge-pool-assignment %s\n" %
                    time.strftime("%Y-%m-%d %H:%M:%S"))
            splitter.dumpAssignments(f)
            f.close()
        except IOError:
            logging.info("I/O error while writing assignments")
示例#4
0
文件: Main.py 项目: sysrqb/bridgedb
    def reload():
        logging.info("Caught SIGHUP")

        # re open config file
        options, arguments = Opt.parseOpts()
        configuration = {}
        if options.configfile:
            execfile(options.configfile, configuration)
            cfg = Conf(**configuration)
            # update loglevel on (re)load
            level = getattr(cfg, "LOGLEVEL", "WARNING")
            level = getattr(logging, level)
            logging.getLogger().setLevel(level)

        load(cfg, splitter, clear=True)
        proxyList.replaceProxyList(loadProxyList(cfg))
        logging.info("%d bridges loaded", len(splitter))
        if emailDistributor:
            emailDistributor.prepopulateRings()  # create default rings
            logging.info("%d for email", len(emailDistributor.splitter))
        if ipDistributor:
            ipDistributor.prepopulateRings()  # create default rings
            logging.info("%d for web:", len(ipDistributor.splitter))
            for (n, (f, r)) in ipDistributor.splitter.filterRings.items():
                logging.info(" by filter set %s, %d" % (n, len(r)))
            # logging.info("  by location set: %s",
            #             " ".join(str(len(r)) for r in ipDistributor.rings))
            # logging.info("  by category set: %s",
            #             " ".join(str(len(r)) for r in ipDistributor.categoryRings))
            # logging.info("Here are all known bridges in the category section:")
            # for r in ipDistributor.categoryRings:
            #    for name, b in r.bridges.items():
            #        logging.info("%s" % b.getConfigLine(True))

        # Dump bridge pool assignments to disk.
        try:
            logging.debug("Dumping pool assignments file")
            f = open(cfg.ASSIGNMENTS_FILE, "a")
            f.write("bridge-pool-assignment %s\n" % time.strftime("%Y-%m-%d %H:%M:%S"))
            splitter.dumpAssignments(f)
            f.close()
        except IOError:
            logging.info("I/O error while writing assignments")
示例#5
0
文件: Main.py 项目: katmagic/BridgeDB
def run():
    """Parse the command line to determine where the configuration is.
       Parse the configuration, and start the servers.
    """
    options, arguments = Opt.parseOpts()
    configuration = {}

    if options.testing:
        configuration = CONFIG
    elif not options.configfile:
        print "Syntax: %s -c CONFIGFILE" % sys.argv[0]
        sys.exit(1)
    else:
        configFile = options.configfile
        execfile(configFile, configuration)
        C = Conf(**configuration)
        configuration = C

    if options.dumpbridges:
        bucketManager = Bucket.BucketManager(configuration)
        bucketManager.assignBridgesToBuckets()
        bucketManager.dumpBridges()
    else:
        startup(configuration)