Пример #1
0
def main():
    # Config: app name (defaults to $0)
    config = Config('beeper.py')
    # define what keys to read from settings / optional cli args
    # if options are not provided by cli args, then they MUST be in the
    # config.
    #
    # -'s in names are read in python as _'s
    # types are optional, but useful for argparse
    config.option('beep-rate', type=float)
    config.option('boop-rate', type=float)

    # parses args, loads the config file, gets options, throws errors
    # if options not satisfied
    config.retrieve()

    socket = pub(*config.uris)

    # can now read config values as proprties of the Config instance
    beep_thread('beep', socket, config.beep_rate).start()
    beep_thread('boop', socket, config.boop_rate).start()

    print 'URIs: ' + str(config.uris)

    try:
        while True:
            sleep(10)
    except KeyboardInterrupt:
        print " keyboard interrupt, exiting."
Пример #2
0
def Config(*args, **kwargs):
    """
    a config object with debug and port options already required
    """
    config = BaseConfig(*args, **kwargs)
    config.option('debug', type=bool)
    config.option('port', type=int)
    return config
Пример #3
0
def Config(*args, **kwargs):
    """
    a config object with debug and port options already required
    """
    config = BaseConfig(*args, **kwargs)
    config.option('debug', type=bool)
    config.option('port', type=int)
    return config