Exemplo n.º 1
0
    parser.add_argument('user', nargs='?', action=UserAction, help='Username')

    args = parser.parse_args()

    if not os.path.exists(args.db_file) and not args.op == "init":
        raise StandardError("File %s does not exist. Use %s %s 'init' if you want to create it" % (args.db_file, sys.argv[0], args.db_file))

    u = UserDB(args.db_file)

    if args.op == 'set':
        pw = getpass.getpass()

        u.set(args.user, pw)
    elif args.op == 'check':
        pw = getpass.getpass()

        cv = u.check(args.user, pw)
        if cv:
            print "Success"
        else:
            print "Failure"
            sys.exit(1)

    elif args.op == 'list':
        print "\n".join(u.list_users())

    elif args.op == 'init':
        u.init_db(args.db_file)


Exemplo n.º 2
0
from flask.ext.mongokit import MongoKit
db = MongoKit(app)

# Mailer
from flask.ext.mail import Mail
mail = Mail(app)

# Login manager for frontend
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login"

# User Auth DB file - create if not existing
if not os.path.exists(app.config.get('USER_DB_FILE')):
    from glider_util.bdb import UserDB
    UserDB.init_db(app.config.get('USER_DB_FILE'))

# Create logging
if app.config.get('LOG_FILE') == True:
    import logging
    from logging import FileHandler
    file_handler = FileHandler('logs/glider_dac.txt')
    formatter = logging.Formatter('%(asctime)s - %(process)d - %(name)s - %(module)s:%(lineno)d - %(levelname)s - %(message)s')
    file_handler.setFormatter(formatter)
    file_handler.setLevel(logging.INFO)
    app.logger.addHandler(file_handler)
    app.logger.info('Application Process Started')

# Create datetime jinja2 filter
def datetimeformat(value, format='%a, %b %d %Y at %I:%M%p'):
    if isinstance(value, datetime.datetime):
Exemplo n.º 3
0
db = MongoKit(app)

# Mailer
from flask_mail import Mail

mail = Mail(app)

# Login manager for frontend
login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login"

# User Auth DB file - create if not existing
if not os.path.exists(app.config.get('USER_DB_FILE')):
    from glider_util.bdb import UserDB
    UserDB.init_db(app.config.get('USER_DB_FILE'))

# Create logging
if app.config.get('LOG_FILE') == True:
    import logging
    from logging import FileHandler
    file_handler = FileHandler('logs/glider_dac.txt')
    formatter = logging.Formatter(
        '%(asctime)s - %(process)d - %(name)s - %(module)s:%(lineno)d - %(levelname)s - %(message)s'
    )
    file_handler.setFormatter(formatter)
    file_handler.setLevel(logging.INFO)
    app.logger.addHandler(file_handler)
    app.logger.info('Application Process Started')

Exemplo n.º 4
0
    parser.add_argument('user', nargs='?', action=UserAction, help='Username')

    args = parser.parse_args()

    if not os.path.exists(args.db_file) and not args.op == "init":
        raise StandardError(
            "File %s does not exist. Use %s %s 'init' if you want to create it"
            % (args.db_file, sys.argv[0], args.db_file))

    u = UserDB(args.db_file)

    if args.op == 'set':
        pw = getpass.getpass()

        u.set(args.user, pw)
    elif args.op == 'check':
        pw = getpass.getpass()

        cv = u.check(args.user, pw)
        if cv:
            print "Success"
        else:
            print "Failure"
            sys.exit(1)

    elif args.op == 'list':
        print "\n".join(u.list_users())

    elif args.op == 'init':
        u.init_db(args.db_file)