Example #1
0
def main ():
    logging.getLogger().setLevel(logging.INFO)

    logging.info('Setting up empty database with approved schema and tables....')
    engine, session = models.setup_tables("../db/empty.db")

    logging.info('Setting up schema and tables....')
    engine, session = models.setup_tables("../db/sample.db")
    models.sess_s = session

    logging.info('Importing US Congressmen as Patients...')
    add_uscongressmen_as_patients(session)

    logging.info('Importing department names from file...')
    add_departments_from_file(session, 'depts.txt')

    logging.info('Adding TN MLAs as doctors...')
    add_doctor_names(session, 'tnmlas.txt')

    logging.info('Setting up Shifts...')
    add_shifts(session)

    logging.info('Setting up Consulting Hours...')
    add_slots(session)

    logging.info('Assigning Departments to doctors...')
    add_departments(session)

    logging.info('Setting up random visits...')
    add_consultations(session)
Example #2
0
File: test_db.py Project: wkfff/PRS
def main():
    engine, session = models.setup_tables()
    session.add(
        models.Patient(name='Donald Rumsfield',
                       age=40,
                       phone='+1 234 456 7890',
                       relative='George Bush'))
    query(session)
Example #3
0
def main():
    args = docopt(__doc__, version='zenfeed ' + VERSION)

    log_arg, log_level = args['--log'].rsplit(':', 1)
    if log_arg not in ('stderr', 'syslog'):
        setup_logger(type='file',
                     filename=path(log_arg).abspath(),
                     level=log_level)
    else:
        setup_logger(type=log_arg, level=log_level)

    logger.info('Zenfeed %s booting...', VERSION)

    if args['genstatic']:
        return genstatic(args['PATH'])

    port = int(args['--port'])

    cache_disabled = args['--no-cache']

    path_prefix = args['--prefix']
    if path_prefix.endswith('/'):
        path_prefix = path_prefix[:-1]
    if path_prefix and not path_prefix.startswith('/'):
        path_prefix = '/' + path_prefix

    fixed_language = args['--lang']
    if fixed_language == 'browser':
        fixed_language = None
    else:
        logger.info('Language fixed to "%s"', fixed_language)
        if (fixed_language not in LANGUAGES
                and fixed_language.split('_', 1)[0] not in LANGUAGES):
            return logger.critical('Fixed language not supported !')

    fixed_timezone = args['--tz']
    logger.info('Timezone fixed to "%s"', fixed_timezone)
    if fixed_timezone not in all_timezones:
        return logger.critical('Fixed timezone not supported !')

    db_uri = args['--database']
    if db_uri == ':memory:':
        db_uri = 'sqlite://'
    elif not "://" in db_uri:
        db_uri = 'sqlite:///%s' % path(db_uri).abspath()

    import app as app_module
    app = app_module.create_flask_app(prefix=path_prefix)
    app.config.update(
        DEBUG=args['--debug'],
        SQL_DEBUG=False,
        SECRET_KEY=urandom(32),
        SQLALCHEMY_DATABASE_URI=db_uri,
        FAVICON_DIR=path(args['--favicons']).abspath(),
        FIXED_LANGUAGE=fixed_language,
        FIXED_TIMEZONE=fixed_timezone,
        CACHE_ENABLED=not cache_disabled,
        PATH_PREFIX=path_prefix,
    )
    Cache(app)

    from models import setup_tables, Feed
    patch_socket()
    patch_ssl()
    setup_tables()

    from deadline_manager import deadlineManager
    import views
    from werkzeug.contrib.fixers import ProxyFix
    app.wsgi_app = ProxyFix(app.wsgi_app)

    feeds = Feed.query.all()
    deadlineManager.favicon_dir = path(args['--favicons']).abspath()
    deadlineManager.launch_deadline_workers(feeds)
    deadlineManager.start()

    logger.info("Server started at port %d (prefix: %s/)", port, path_prefix)
    if args['--debug']:
        logger.warning("DEBUG mode activated")
        app.run(host='0.0.0.0', port=port, debug=True)
    else:
        from gevent.wsgi import WSGIServer
        http_server = WSGIServer(('0.0.0.0', port), app)
        try:
            http_server.serve_forever()
        except KeyboardInterrupt:
            pass
Example #4
0
def main():
    args = docopt(__doc__, version='zenfeed ' + VERSION)

    log_arg, log_level = args['--log'].rsplit(':', 1)
    if log_arg not in ('stderr', 'syslog'):
        setup_logger(type='file', filename=path(log_arg).abspath(),
                     level=log_level)
    else:
        setup_logger(type=log_arg, level=log_level)

    logger.info('Zenfeed %s booting...', VERSION)

    if args['genstatic']:
        return genstatic(args['PATH'])

    port = int(args['--port'])

    cache_disabled = args['--no-cache']

    path_prefix = args['--prefix']
    if path_prefix.endswith('/'):
        path_prefix = path_prefix[:-1]
    if path_prefix and not path_prefix.startswith('/'):
        path_prefix = '/' + path_prefix

    fixed_language = args['--lang']
    if fixed_language == 'browser':
        fixed_language = None
    else:
        logger.info('Language fixed to "%s"', fixed_language)
        if (fixed_language not in LANGUAGES
            and fixed_language.split('_', 1)[0] not in LANGUAGES):
            return logger.critical('Fixed language not supported !')

    fixed_timezone = args['--tz']
    logger.info('Timezone fixed to "%s"', fixed_timezone)
    if fixed_timezone not in all_timezones:
        return logger.critical('Fixed timezone not supported !')

    db_uri = args['--database']
    if db_uri == ':memory:':
        db_uri = 'sqlite://'
    elif not "://" in db_uri:
        db_uri = 'sqlite:///%s' % path(db_uri).abspath()

    import app as app_module
    app = app_module.create_flask_app(prefix=path_prefix)
    app.config.update(
        DEBUG = args['--debug'],
        SQL_DEBUG = False,
        SECRET_KEY = urandom(32),
        SQLALCHEMY_DATABASE_URI = db_uri,
        FAVICON_DIR = path(args['--favicons']).abspath(),
        FIXED_LANGUAGE = fixed_language,
        FIXED_TIMEZONE = fixed_timezone,
        CACHE_ENABLED = not cache_disabled,
        PATH_PREFIX = path_prefix,
    )
    Cache(app)

    from models import setup_tables, Feed
    patch_socket()
    patch_ssl()
    setup_tables()

    from deadline_manager import deadlineManager
    import views
    from werkzeug.contrib.fixers import ProxyFix
    app.wsgi_app = ProxyFix(app.wsgi_app)

    feeds = Feed.query.all()
    deadlineManager.favicon_dir = path(args['--favicons']).abspath()
    deadlineManager.launch_deadline_workers(feeds)
    deadlineManager.start()

    logger.info("Server started at port %d (prefix: %s/)", port, path_prefix)
    if args['--debug']:
        logger.warning("DEBUG mode activated")
        app.run(host='0.0.0.0', port=port, debug=True)
    else:
        from gevent.wsgi import WSGIServer
        http_server = WSGIServer(('0.0.0.0', port), app)
        try:
            http_server.serve_forever()
        except KeyboardInterrupt:
            pass
Example #5
0
def main ():
    engine, session = models.setup_tables()
    session.add(models.Patient(name='Donald Rumsfield',
                               age=40, phone='+1 234 456 7890',
                               relative='George Bush'))
    query(session)