def get_database(fresh_config=False): config = read_config_file() DATABASE = config.get('database', 'file') if DATABASE.startswith('/'): DATABASE = 'sqlite:///{}'.format(DATABASE) return connect(DATABASE)
def is_already_installed(): try: from pantry.config import read_config_file config = read_config_file() config.get('database', 'file') return True except: pass return False
def check_session_limit(): config = read_config_file() if 'logged_in' in session and session.get('last_activity') is not None: now = int(time.time()) limit = 3600 try: limit = now - 60 * int(config.get('session', 'time')) except: pass last_activity = session.get('last_activity') if last_activity < limit: flash(u'Session timed out !', 'info') session.pop('logged_in', None) session.pop('token', None) session.pop('last_activity', None) session.pop('username', None) session.pop('name', None) session.pop('su', None) flash(u'You are logged out!', 'success') else: session['last_activity'] = now
# -*- coding: utf-8 -*- from __future__ import absolute_import, print_function import time from flask import Blueprint, request, session, redirect, url_for, render_template, flash from pantry.utils import get_token from pantry.config import read_config_file import pantry.authenticators as auth config = read_config_file() if 'setup_mode' in config['global'] and config['global']['setup_mode'] == 'True': print(' * Setup mode') AUTH = False AUTH_INSTANCE = auth.get_authenticator(AUTH) else: AUTH = read_config_file().get('global', 'auth') AUTH_INSTANCE = auth.get_authenticator(AUTH) print(' * Auth type: ' + AUTH) # Flask module mod = Blueprint('auth', __name__) @mod.route('/login', methods=['GET', 'POST']) def login():
from pantry.config import read_config_file from pantry.app import app #import logging if __name__ == "__main__": #gunicorn_logger = logging.getLogger('gunicorn.error') #app.logger.handlers = gunicorn_logger.handlers #app.logger.setLevel(gunicorn_logger.level) config = read_config_file() #app.config['DEBUG'] = True app.run(host=app.config['ADDRESS'], port=app.config['PORT'])