Beispiel #1
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
Beispiel #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
Beispiel #3
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."
Beispiel #4
0
def main():
    # we don't care about the value because we're only interested in service
    # definitions. Unfortunatley you may need a dummy service definition
    Config().retrieve()
    uris = Service.all_uris()

    if len(uris) == 0:
        print('No URIs! Exiting.')
        return

    print('Will listen to uris: ' + str(uris))

    for u in uris:
        create_listener_thread(u).start()

    try:
        while True:
            sleep(1)
    except KeyboardInterrupt:
        print(' keyboard interrupt, exiting.')
        return