Ejemplo n.º 1
0
def run():
    parser = optparse.OptionParser()
    # options we can override in the config file.
    groupConfigFile = optparse.OptionGroup(parser, "Config File Defaults",
                                           "All the options which have defaults read from a config file.")
    parser.add_option_group(groupConfigFile)
    parser.add_option_group(groupConfigFile)

    parser.add_option("--config", dest="config", default="web/web.conf",
                      help="Config file to read settings from, defaults to web.conf which will be read from configs/ and /etc/pybit/ in turn.",
                      metavar=META + "CONF_FILE")

    parser.add_option("-v", dest="verbose", action="store_true", default=False,
                      help="Turn on verbose messages.", metavar=META+"VERBOSE")
    (options, args) = parser.parse_args()
    (settings, opened_file) = pybit.load_settings(options.config)
    settings = pybit.merge_options(settings, groupConfigFile, options)

    # singleton instance
    myDb = Database(settings['db'])
    # singleton instance - Needs access to both controller and web settings
    buildController = Controller(settings, myDb)

    app = cnx_pybit.get_app(settings, myDb, buildController)
    bottle.debug(options.verbose)
    bottle.run(app=app,
               server=settings['web']['app'],
               host=settings['web']['interface'],
               port=settings['web']['port'],
               reloader=settings['web']['reloader'],
               )
Ejemplo n.º 2
0
    parser = optparse.OptionParser()
    #options we can override in the config file.
    groupConfigFile = optparse.OptionGroup(parser,
        "Config File Defaults","All the options which have defaults read from a config file.")
    parser.add_option_group(groupConfigFile)
    parser.add_option_group(groupConfigFile)

    parser.add_option("--config", dest="config", default="web/web.conf",
        help="Config file to read settings from, defaults to web.conf which will be read from configs/ and /etc/pybit/ in turn.",
        metavar=META + "CONF_FILE")

    parser.add_option("-v", dest="verbose", action="store_true", default=False,
        help="Turn on verbose messages.", metavar=META+"VERBOSE")
    (options, args) = parser.parse_args()
    (settings, opened_file) = pybit.load_settings(options.config)
    settings = pybit.merge_options(settings, groupConfigFile, options)
    
    FORMAT = '%(asctime)s %(filename)s:%(lineno)d %(msg)s'
    logging.basicConfig( stream=sys.stderr, level=logging.WARN)
    logging.basicConfig( format=FORMAT )
    
    myDb = Database(settings['db']) # singleton instance
    buildController = Controller(settings, myDb) # singleton instance - Needs access to both controller and web settings
#   try:
    app = pybitweb.get_app(settings, myDb, buildController)
    bottle.debug(options.verbose)
    bottle.run(app=app,
        server=settings['web']['app'],
        host=settings['web']['interface'],
        port=settings['web']['port'],
        reloader=settings['web']['reloader'])