예제 #1
0
def start():
    """ Update the database schema """
    try:
        from handlers import update_db

        update_db()
    except Exception as error:
        logging.error("Error: %s" % error)
        if "Can't locate revision identified" not in str(error):
            # Skipped if alembic record ahead for branch compatibility
            os._exit(1)
    """ Starts the application """
    from handlers import start_server

    prefix = "https://" if options.ssl else "http://"
    # TODO For docker, it would be nice to grab the mapped docker port
    listenport = C + "%slocalhost:%s" % (prefix, str(options.listen_port)) + W
    sys.stdout.flush()
    try:
        print(INFO + bold + R + "Starting RTB on %s" % listenport, flush=True)
    except:
        print(INFO + bold + R + "Starting RTB on %s" % listenport)

    result = start_server()
    if result == "restart":
        restart()
예제 #2
0
def start():
    """ Update the database schema """
    try:
        from handlers import update_db

        update_db()
    except Exception as error:
        logging.error("Error: %s" % error)
        if "Can't locate revision identified" not in str(error):
            # Skipped if alembic record ahead for branch compatibility
            os._exit(1)
    """ Starts the application """
    from handlers import start_server, load_history

    load_history()

    prefix = "https://" if options.ssl else "http://"
    # TODO For docker, it would be nice to grab the mapped docker port
    listenport = C + "%slocalhost:%s" % (prefix, str(options.listen_port)) + W
    sys.stdout.flush()
    try:
        print(INFO + bold + R + "Starting RTB on %s" % listenport, flush=True)
    except TypeError:
        print(INFO + bold + R + "Starting RTB on %s" % listenport)
    if len(options.mail_host) > 0 and "localhost" in options.origin:
        logging.warning(
            "%sWARNING:%s Invalid 'origin' configuration (localhost) for Email support %s"
            % (WARN + bold + R, W, WARN))

    result = start_server()
    if result == "restart":
        restart()
예제 #3
0
def start():
    """ Update the database schema """
    try:
        from handlers import update_db

        update_db()
    except Exception as error:
        logging.error("Error: %s" % error)
        if "Can't locate revision identified" not in str(error):
            # Skipped if alembic record ahead for branch compatibility
            os._exit(1)

    """ Starts the application """
    from handlers import start_server

    if options.setup.startswith("docker"):
        # Would be nice to grab this info from the container in case it is changed
        port = "80:8888"
        listenport = "Docker port mapping " + port
    else:
        listenport = "port " + str(options.listen_port)
    print(INFO + bold + G + "Starting RTB on %s" % listenport)

    result = start_server()
    if result == "restart":
        restart()
예제 #4
0
def setup():
    """
    Creates/bootstraps the database.

    If you're a real developer you'll figure out how to remove the
    warning yourself. Don't merge any code the removes it.
    """
    is_devel = options.setup.startswith("dev")
    if is_devel:
        print("%sWARNING:%s Setup is in development mode %s" %
              (WARN + bold, W, WARN))
        message = "I know what the f**k I am doing"
        resp = input(PROMPT + 'Please type "%s": ' % message)
        if resp.replace('"', "").lower().strip() != message.lower():
            os._exit(1)
    print(INFO + "%s : Creating the database ..." % current_time())
    from setup.create_database import create_tables, engine, metadata

    create_tables(engine, metadata, is_devel)
    print(INFO + "%s : Bootstrapping the database ..." % current_time())
    import setup.bootstrap

    # Display Details
    if is_devel:
        environ = bold + R + "Development boot strap" + W
        details = ", admin password is 'nimda123'."
    else:
        environ = bold + "Production boot strap" + W
        details = "."
    from handlers import update_db

    update_db(False)
    print(INFO + "%s completed successfully%s" % (environ, details))
예제 #5
0
def setup():
    '''
    Creates/bootstraps the database.

    If you're a real developer you'll figure out how to remove the
    warning yourself. Don't merge any code the removes it.
    '''
    is_devel = options.setup.startswith('dev')
    if is_devel:
        print("%sWARNING:%s Setup is in development mode %s" % (
            WARN + bold, W, WARN,
        ))
        message = "I know what the f**k I am doing"
        resp = raw_input(PROMPT + 'Please type "%s": ' % message)
        if resp.replace('"', '').lower().strip() != message.lower():
            os._exit(1)
    print(INFO + '%s : Creating the database ...' % current_time())
    from setup.create_database import create_tables, engine, metadata
    create_tables(engine, metadata, is_devel)
    print(INFO + '%s : Bootstrapping the database ...' % current_time())
    import setup.bootstrap
    # Display Details
    if is_devel:
        environ = bold + R + "Development boot strap" + W
        details = ", admin password is 'nimda123'."
    else:
        environ = bold + "Production boot strap" + W
        details = '.'
    from handlers import update_db
    update_db(False)
    print(INFO + '%s completed successfully%s' % (environ, details))
예제 #6
0
def start():
    ''' Update the database schema '''
    from handlers import update_db
    update_db()
    ''' Starts the application '''
    from handlers import start_server
    logging.info(INFO + '%s : Starting application ...' % current_time())
    start_server()
예제 #7
0
def start():
    ''' Update the database schema '''
    from handlers import update_db
    update_db()

    ''' Starts the application '''
    from handlers import start_server
    logging.info(INFO + '%s : Starting RTB on port %s' % (current_time(), options.listen_port))
    start_server()
예제 #8
0
def start():
    ''' Update the database schema '''
    try:
        from handlers import update_db
        update_db()
    except Exception as error:
        logging.error("Error: %s" % error)
        os._exit(1)

    ''' Starts the application '''
    from handlers import start_server
    logging.info(INFO + '%s : Starting RTB on port %s' % (current_time(), options.listen_port))
    start_server()
예제 #9
0
def start():
    ''' Update the database schema '''
    try:
        from handlers import update_db
        update_db()
    except:
        logging.fatal("Error: Unable to verify the db schema.  '--setup=prod' or '--setup=dev' can be used to create the database.")
        os._exit(1)

    ''' Starts the application '''
    from handlers import start_server
    logging.info(INFO + '%s : Starting RTB on port %s' % (current_time(), options.listen_port))
    start_server()
예제 #10
0
def start():
    ''' Update the database schema '''
    try:
        from handlers import update_db
        update_db()
    except Exception as error:
        logging.error("Error: %s" % error)
        if "Can't locate revision identified" not in str(error):
            #Skipped if alembic record ahead for branch compatibility
            os._exit(1)
    ''' Starts the application '''
    from handlers import start_server
    logging.info(INFO + '%s : Starting RTB on port %s' %
                 (current_time(), options.listen_port))
    start_server()
예제 #11
0
def start():
    ''' Update the database schema '''
    try:
        from handlers import update_db
        update_db()
    except Exception as error:
        logging.error("Error: %s" % error)
        if "Can't locate revision identified" not in str(error):
            #Skipped if alembic record ahead for branch compatibility
            os._exit(1)
        
    ''' Starts the application '''
    from handlers import start_server
    logging.info(INFO + '%s : Starting RTB on port %s' % (current_time(), options.listen_port))
    start_server()
예제 #12
0
def setup():
    """
    Creates/bootstraps the database.

    If you're a real developer you'll figure out how to remove the
    warning yourself. Don't merge any code the removes it.
    """
    is_devel = options.setup.startswith("dev")
    if is_devel:
        print("%sWARNING:%s Setup is in development mode %s" %
              (WARN + bold, W, WARN))
        message = "I know what the f**k I am doing"
        resp = input(PROMPT + 'Please type "%s": ' % message)
        if resp.replace('"', "").lower().strip() != message.lower():
            os._exit(1)
    else:
        is_devel = options.setup.startswith("docker")
    print(INFO + "%s : Creating the database ..." % current_time())
    from setup.create_database import create_tables, engine, metadata

    create_tables(engine, metadata, options.log_sql)
    sys.stdout.flush()

    from models.Theme import Theme

    themes = Theme.all()
    if len(themes) > 0:
        print(INFO + "It looks like database has already been set up.")
        return

    print(INFO + "%s : Bootstrapping the database ..." % current_time())
    import setup.bootstrap

    # Display Details
    if is_devel:
        environ = bold + R + "Development bootstrap:"
        details = C + "Admin Username: admin, Password: rootthebox" + W
    else:
        environ = bold + "Production bootstrap" + W
        details = ""
    from handlers import update_db

    update_db(False)
    sys.stdout.flush()
    try:
        print(INFO + "%s %s" % (environ, details), flush=True)
    except:
        print(INFO + "%s %s" % (environ, details))