Esempio n. 1
0
    if not account.role:
        raise ValueError('no role given')
    if not account.role in constants.ACCOUNT_ROLES:
        raise ValueError('invalid role given')
    account.state = constants.ENABLED
    password = getpass.getpass('password > ')
    if password:
        confirm = getpass.getpass('confirm password > ')
        if password != confirm:
            raise ValueError('passwords did not match')
    else:
        password = ''
    account.password = password
    db.create_account(account, dict(user_agent='commandline'))
    if verbose:
        print('created account', username)


if __name__ == '__main__':
    args = utils.get_args()
    settings = utils.load_settings(filepath=args.settings, verbose=args.verbose)
    db = utils.dbi.Database(settings)
    db.check_version()
    if args.verbose:
        print('database', db)
    try:
        create_account_commandline(db, verbose=args.verbose)
    except ValueError as msg:
        sys.exit(msg)

Esempio n. 2
0
    handlers.append(url('(.*)', NotFoundError))

    application = tornado.web.Application(
        handlers=handlers,
        debug=settings['TORNADO_DEBUG'],
        cookie_secret=settings['COOKIE_SECRET'],
        xsrf_cookies=True,
        login_url='/login',
        ui_modules=uimodules,
        static_path='static',
        template_path='html',
        template_whitespace='single',
        **settings)
    # xheaders argument takes care of X-Real-Ip and X-Forwarded-For
    application.listen(settings['PORT'], xheaders=True)
    pid = os.getpid()
    logging.info("web server PID %s on port %s", pid, settings['PORT'])
    try:
        with open(settings['PIDFILE_FILEPATH'], 'w') as outfile:
            outfile.write(str(pid))
    except KeyError:
        pass
    tornado.ioloop.IOLoop.instance().start()


if __name__ == "__main__":
    args = utils.get_args()
    main(utils.load_settings(filepath=args.settings,
                             pidfile=args.pidfile,
                             verbose=args.verbose))