Exemplo n.º 1
0
def main():
    # Parser arguments
    parser = argparse.ArgumentParser()
    parser.add_argument('--host', required=False, default='0.0.0.0')
    parser.add_argument('--port', required=False, default=8080)
    parser.add_argument('--debug', required=False, action='store_true')
    args = parser.parse_args()

    # Create the logger
    setLogger()

    # Run Server
    print("Starting server for %s on port %s" %(args.host, args.port))
    bottle_debug(args.debug)
    httpserver.serve(app, host='0.0.0.0', port=80)
Exemplo n.º 2
0
def run_ui(debug=False, host='0.0.0.0', port=50505, browser=True):
    """
    :param debug:  to run bottle in mode debug, default False.
    :param host: where to run the app, default localhost.
    :param port: port of the app, default None.
    :param browser: open browser when run, default True.
    :return:
    """

    # If not specified search for a free port.
    if not port:
        port = get_free_port()
    # Open browser.
    if browser:
        th = threading.Thread()
        th.run = lambda: open_browser(port)
        th.start()
    bottle_debug(debug)
    app.run(host=host, port=port)

    return
Exemplo n.º 3
0
def main():
    global conf
    conf = ConfReader('hedgehog.ini')
    try:
        bug_caching_time = int(conf.bug_caching_time)
    except:
        log.error("The bug_caching_time directive in the configuration time must be\
 an integer.")

    # logging
    if conf.debug:
        logging.basicConfig(
            level=logging.DEBUG,
            format='%(asctime)s [%(process)d] %(levelname)s %(name)s (%(funcName)s)\
 %(message)s',
            datefmt = '%Y-%m-%d %H:%M:%S' # %z for timezone
        )
        log.debug("Debug mode")
        bottle_debug(True)
        reload = True
    else:
        logging.basicConfig(
            level=logging.DEBUG,
            format='%(asctime)s [%(process)d] %(levelname)s %(name)s %(message)s',
            datefmt = '%Y-%m-%d %H:%M:%S' # %z for timezone
            #TODO: add filename=conf.logfile
        )
        reload = False

    log.info('Starting...')
    app = cork.setup(conf) # AAA wrapper
    run(app=app, host=conf.listen_address, port=conf.listen_port, reloader=conf.debug)
   
    # wait here until the daemon is killed

    log.info("Terminating daemon...")
    #savedb(db, 'db.gz')
    log.info("Terminated.")
Exemplo n.º 4
0
        conf = ConfReader(fn=fn)
        if conf.ip_list_netflow_weight == 'byt' or conf.ip_list_netflow_weight == 'bps':
            conf.scale_factor *= 0.001  # Avoid huge circles when scaling with bytes or bps
    except Exception, e:
        log.error("Exception %s while reading configuration file '%s'" % (e, fn))
        exit(1)

    # logging

    if '-D' in argv:
        debug_mode = True
        log.basicConfig(level=log.DEBUG,
                        format='%(asctime)s %(levelname)-8s %(message)s',
                        datefmt='%a, %d %b %Y %H:%M:%S')
        log.debug("Debug mode")
        bottle_debug(True)
    else:
        debug_mode = False
        log.basicConfig(level=log.INFO,
                    format='%(asctime)s %(levelname)-8s %(message)s',
                    datefmt='%a, %d %b %Y %H:%M:%S',
                    filename=conf.logfile,
                    filemode='w')

    # also depends on libjs-jquery-ui
    try:
        import GeoIP
    except ImportError:
        log.error("Error: GeoIP module not imported.")

    try:
Exemplo n.º 5
0
    if args.repodir:
        conf.data_dir = args.repodir
    logfile = args.logfile if args.logfile else conf.logfile

    # setup logging
    logging.basicConfig(
        level=logging.DEBUG,
        format='%(asctime)s [%(process)d] %(levelname)s %(name)s (%(funcName)s) %(message)s',
        datefmt = '%Y-%m-%d %H:%M:%S' # %z for timezone
    )
    log.addHandler(web_log_handler)
    if args.debug:
        log.debug("Debug mode")
        log.debug("Configuration file: %r", args.cf)
        log.debug("Logfile (unused in debug mode): %r", logfile)
        bottle_debug(True)

    else:
        logging.basicConfig(
            level=logging.DEBUG,
        )
        fh = logging.handlers.TimedRotatingFileHandler(
            logfile,
            when='midnight',
            utc=True,
        )
        fh.setLevel(logging.DEBUG)
        fh.setFormatter(logging.Formatter(
            '%(asctime)s [%(process)d] %(levelname)s %(name)s %(module)s:%(funcName)s:%(lineno)s %(message)s'))
        log.addHandler(fh)