コード例 #1
0
ファイル: beeper.py プロジェクト: LeadDevCM/squidwork
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."