示例#1
0
 def test_location_interpolation(self):
     config = Config(self.file_one)
     # file_one is a StringIO, so it has no location.
     self.assertEquals(config.get('one', 'location'), '${HERE}')
     # file_two is a real file, so it has a location.
     file_two_loc = os.path.dirname(self.file_two)
     self.assertEquals(config.get('three', 'location'), file_two_loc)
示例#2
0
def main(args=None):
    # 1. read the command-line options
    args = _read_args(args)

    if args.version:
        print(__version__)
        sys.exit(0)

    # 2. grab the config
    from konfig import Config
    config = Config(args.config).get_map('udun')

    # 3. grab things in the redis list
    events = _get_redis_events(config.get('redis_host', 'localhost'),
                               config.get('redis_port', 6379),
                               config.get('redis_listname', 'udun'))

    # 4. combine per-collection
    collection_ids = _get_impacted_collections(events)

    # 5. send it to Balrog
    _poke_balrog(collection_ids)
示例#3
0
def main(args=None):
    # 1. read the command-line options
    args = _read_args(args)

    if args.version:
        print(__version__)
        sys.exit(0)

    # 2. grab the config
    from konfig import Config
    config = Config(args.config).get_map('udun')

    # 3. grab things in the redis list
    events = _get_redis_events(config.get('redis_host', 'localhost'),
                               config.get('redis_port', 6379),
                               config.get('redis_listname', 'udun'))

    # 4. combine per-collection
    collection_ids = _get_impacted_collections(events)

    # 5. send it to Balrog
    _poke_balrog(collection_ids)
示例#4
0
    def test_reader(self):
        config = Config(self.file_one)

        # values conversion
        self.assertMultiLineEqual(config.get('one', 'foo'), 'bar')
        self.assertTrue(config.get('one', 'num') == -12)
        self.assertMultiLineEqual(config.get('one', 'not_a_num'), "12abc")
        self.assertMultiLineEqual(config.get('one', 'st'), 'o=k')
        self.assertListEqual(config.get('one', 'lines'), [1, 'two', 3])
        self.assertMultiLineEqual(config.get('one', 'env'), 'some stuff')

        # getting a map
        _map = config.get_map()
        self.assertMultiLineEqual(_map['one.foo'], 'bar')

        _map = config.get_map('one')
        self.assertMultiLineEqual(_map['foo'], 'bar')

        del os.environ['__STUFF__']
        self.assertMultiLineEqual(config.get('one', 'env'), 'some stuff')

        # extends
        self.assertMultiLineEqual(config.get('three', 'more'), 'stuff')
        self.assertMultiLineEqual(config.get('one', 'two'), 'a')
示例#5
0
def main():
    configure_logger()
    if len(sys.argv) > 1:
        ini = sys.argv[1]
    else:
        ini = "kompost.ini"
    os.environ["CURDIR"] = os.getcwd()
    config = Config(codecs.open(ini, "r", "utf8"))
    config = dict(config.items("kompost"))
    target = config["target"]
    src = config["src"]
    socket.setdefaulttimeout(int(config.get("timeout", 10)))
    config["media"] = os.path.abspath(os.path.join(target, "media"))
    config["generic"] = os.path.join(src, "generic.mako")
    config["cats"] = os.path.join(src, "category.mako")
    config["icons"] = ("pen.png", "info.png", "thumbsup.png", "right.png", "flash.png")
    config["metadata"] = os.path.join(target, "metadata.json")
    generate(config)
    pdf(config)
示例#6
0
文件: importer.py 项目: v1ka5/ichnaea
def main(argv):
    parser = argparse.ArgumentParser(prog=argv[0], description="Location Importer")

    parser.add_argument("--dry-run", action="store_true")
    # TODO rely on ICHNAEA_CFG / ichnaea.config, as the worker is relying
    # on it anyways
    parser.add_argument("config", help="config file")
    parser.add_argument("source", help="source file")
    args = parser.parse_args(argv[1:])
    settings = Config(args.config).get_map("ichnaea")
    db = Database(settings["db_master"], socket=settings.get("db_master_socket"), create=False)
    session = db.session()
    added = load_file(session, args.source)
    print("Added %s records." % added)
    if args.dry_run:
        session.rollback()
    else:  # pragma: no cover
        session.commit()
    return added
示例#7
0
def main():
    configure_logger()
    if len(sys.argv) > 1:
        ini = sys.argv[1]
    else:
        ini = "kompost.ini"
    os.environ['CURDIR'] = os.getcwd()
    config = Config(codecs.open(ini, "r", "utf8"))
    config = dict(config.items('kompost'))
    target = config['target']
    src = config['src']
    socket.setdefaulttimeout(int(config.get('timeout', 10)))
    config['media'] = os.path.abspath(os.path.join(target, 'media'))
    config['generic'] = os.path.join(src, 'generic.mako')
    config['cats'] = os.path.join(src, 'category.mako')
    config['icons'] = ('pen.png', 'info.png', 'thumbsup.png', 'right.png',
                       'flash.png')
    config['metadata'] = os.path.join(target, 'metadata.json')
    generate(config)
    pdf(config)
示例#8
0
 def test_utf8(self):
     utf8 = os.path.join(os.path.dirname(__file__), 'utf8.ini')
     config = Config(utf8)
     self.assertEqual(config.get('ok', 'yeah'), u'é')
示例#9
0
 def test_override_mode(self):
     config = Config(self.file_override)
     self.assertEquals(config.get('one', 'foo'), 'baz')
     self.assertEquals(config.get('three', 'more'), 'stuff')