Blame runserver.py

Pierre-Yves Chibon f92068
#!/usr/bin/env python2
Pierre-Yves Chibon 2088eb
Pierre-Yves Chibon fb4210
# These two lines are needed to run on EL6
Pierre-Yves Chibon ee9b42
__requires__ = ['SQLAlchemy >= 0.8', 'jinja2 >= 2.4']
Pierre-Yves Chibon 2088eb
import pkg_resources
Pierre-Yves Chibon 2088eb
Pierre-Yves Chibon d04562
import argparse
Pierre-Yves Chibon 281f75
import sys
Pierre-Yves Chibon d04562
import os
Pierre-Yves Chibon 281f75
Pierre-Yves Chibon 281f75
Pierre-Yves Chibon d04562
parser = argparse.ArgumentParser(
Pierre-Yves Chibon d04562
    description='Run the packages2 app')
Pierre-Yves Chibon d04562
parser.add_argument(
Pierre-Yves Chibon d04562
    '--config', '-c', dest='config',
Pierre-Yves Chibon d04562
    help='Configuration file to use for packages.')
Pierre-Yves Chibon d04562
parser.add_argument(
Pierre-Yves Chibon d04562
    '--debug', dest='debug', action='store_true',
Pierre-Yves Chibon d04562
    default=False,
Pierre-Yves Chibon d04562
    help='Expand the level of data returned.')
Pierre-Yves Chibon d04562
parser.add_argument(
Pierre-Yves Chibon d04562
    '--profile', dest='profile', action='store_true',
Pierre-Yves Chibon d04562
    default=False,
Pierre-Yves Chibon d04562
    help='Profile the packages2 application.')
Pierre-Yves Chibon d04562
parser.add_argument(
Pierre-Yves Chibon d04562
    '--port', '-p', default=5000,
Pierre-Yves Chibon d04562
    help='Port for the flask application.')
Pierre-Yves Chibon d04562
Pierre-Yves Chibon d04562
args = parser.parse_args()
Pierre-Yves Chibon d04562
Sayan Chowdhury 290e20
from pagure import APP
Sayan Chowdhury 290e20
Pierre-Yves Chibon d04562
if args.profile:
Pierre-Yves Chibon d04562
    from werkzeug.contrib.profiler import ProfilerMiddleware
Pierre-Yves Chibon 281f75
    APP.config['PROFILE'] = True
Pierre-Yves Chibon 281f75
    APP.wsgi_app = ProfilerMiddleware(APP.wsgi_app, restrictions=[30])
Pierre-Yves Chibon 281f75
Pierre-Yves Chibon d04562
if args.config:
Pierre-Yves Chibon 0dcb38
    config = args.config
Pierre-Yves Chibon 0dcb38
    if not config.startswith('/'):
Pierre-Yves Chibon 0dcb38
        here = os.path.join(os.path.dirname(os.path.abspath(__file__)))
Pierre-Yves Chibon 0dcb38
        config = os.path.join(here, config)
Pierre-Yves Chibon 0dcb38
    os.environ['PAGURE_CONFIG'] = config
Pierre-Yves Chibon 182e33
Pierre-Yves Chibon 182e33
APP.debug = True
Ryan Lerch 0db4c7
APP.run(host='0.0.0.0', port=int(args.port))