Beispiel #1
0
def start_server():
    if is_running(get_pid()):
        yellow("Server is already running")
        return

    try:
        open(config.PIDFILE, 'w')
    except IOError:
        red("PID file not writeable (%s) " % config.PIDFILE)
        return

    flags = '--daemon --pid %s' % config.PIDFILE

    green("Server started. Port: %s" % config.PORT)

    config_path = config.get_path()
    if config_path:
        green("Using config: %s" % config_path)
    else:
        yellow("Using default configuration")

    prefix = ''
    if in_virtualenv():
        prefix = get_prefix() + "/bin/"

    Popen("%sgunicorn 'realms:create_app()' -b 0.0.0.0:%s -k gevent %s" %
          (prefix, config.PORT, flags), shell=True, executable='/bin/bash')
Beispiel #2
0
def start_server():
    if is_running(get_pid()):
        yellow("Server is already running")
        return

    try:
        open(config.PIDFILE, 'w')
    except IOError:
        red("PID file not writeable (%s) " % config.PIDFILE)
        return

    flags = '--daemon --pid %s' % config.PIDFILE

    green("Server started. Port: %s" % config.PORT)

    config_path = config.get_path()
    if config_path:
        green("Using config: %s" % config_path)
    else:
        yellow("Using default configuration")

    prefix = ''
    if in_virtualenv():
        prefix = get_prefix() + "/bin/"

    Popen("%sgunicorn 'realms:create_app()' -b 0.0.0.0:%s -k gevent %s" %
          (prefix, config.PORT, flags),
          shell=True,
          executable='/bin/bash')
Beispiel #3
0
def configure(json_string):
    """ Set config, expects JSON encoded string
    """
    try:
        config.update(json.loads(json_string))
    except ValueError, e:
        red('Config value should be valid JSON')
Beispiel #4
0
def configure(json_string):
    """ Set config, expects JSON encoded string
    """
    try:
        config.update(json.loads(json_string))
    except ValueError, e:
        red('Config value should be valid JSON')
Beispiel #5
0
def create_user(username, email, password):
    """ Create a new user
    """
    show_pass = not password

    if not password:
        password = random_string(12)

    if User.get_by_username(username):
        red("Username %s already exists" % username)
        return

    if User.get_by_email(email):
        red("Email %s already exists" % email)
        return

    User.create(username, email, password)
    green("User %s created" % username)

    if show_pass:
        yellow("Password: %s" % password)