예제 #1
0
def db_setup(datadir):
    # Workaround for https://github.com/mitsuhiko/flask-sqlalchemy/pull/250
    tables.metadata.create_all(db.engine)
    if db.session.query(tables.Event).count():
        print('Skipping DB reload')
        return
    get_db(datadir, engine=db.engine)
예제 #2
0
def test_at_least_one_event_present():
    # This loads the DB, making sure it *can* be loaded
    from pyvodb.load import get_db
    from pyvodb.tables import Event
    db = get_db(str(data_dir))
    cnt = db.query(Event).count()
    print(cnt)
    if not cnt:
        exit("no events found")
예제 #3
0
def cli(ctx, data, verbose, color, format, editor):
    """Query a meetup database.
    """
    ctx.obj['verbose'] = verbose
    if verbose:
        logging.basicConfig(level=logging.INFO)
        logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
    ctx.obj['datadir'] = os.path.abspath(data)
    if 'db' not in ctx.obj:
        ctx.obj['db'] = get_db(data)
    if color is None:
        ctx.obj['term'] = blessings.Terminal()
    elif color is True:
        ctx.obj['term'] = blessings.Terminal(force_styling=True)
    elif color is False:
        ctx.obj['term'] = blessings.Terminal(force_styling=None)
    if 'PYVO_TEST_NOW' in os.environ:
        # Fake the current date for testing
        ctx.obj['now'] = datetime.datetime.strptime(
            os.environ['PYVO_TEST_NOW'], '%Y-%m-%d %H:%M:%S')
    else:
        ctx.obj['now'] = datetime.datetime.now()
    ctx.obj['format'] = format
    ctx.obj['editor'] = shlex.split(editor)
예제 #4
0
파일: top.py 프로젝트: pyvec/pyvodb
def cli(ctx, data, verbose, color, format, editor):
    """Query a meetup database.
    """
    ctx.obj['verbose'] = verbose
    if verbose:
        logging.basicConfig(level=logging.INFO)
        logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
    ctx.obj['datadir'] = os.path.abspath(data)
    if 'db' not in ctx.obj:
        ctx.obj['db'] = get_db(data)
    if color is None:
        ctx.obj['term'] = blessings.Terminal()
    elif color is True:
        ctx.obj['term'] = blessings.Terminal(force_styling=True)
    elif color is False:
        ctx.obj['term'] = blessings.Terminal(force_styling=None)
    if 'PYVO_TEST_NOW' in os.environ:
        # Fake the current date for testing
        ctx.obj['now'] = datetime.datetime.strptime(
            os.environ['PYVO_TEST_NOW'], '%Y-%m-%d %H:%M:%S')
    else:
        ctx.obj['now'] = datetime.datetime.now()
    ctx.obj['format'] = format
    ctx.obj['editor'] = shlex.split(editor)
예제 #5
0
파일: test_load.py 프로젝트: encukou/pyvodb
def db():
    directory = os.path.join(os.path.dirname(__file__), 'data')
    return get_db(directory)
예제 #6
0
def empty_db(data_directory):
    return get_db(None)
예제 #7
0
파일: test_load.py 프로젝트: pyvec/pyvodb
def db(data_directory):
    return get_db(data_directory)
예제 #8
0
파일: test_load.py 프로젝트: pyvec/pyvodb
def empty_db(data_directory):
    return get_db(None)
예제 #9
0
def db(data_directory):
    return get_db(data_directory)