Пример #1
0
 def Session_factory():
     engine = models.create_engine_from_config(
         utils.balaio_config_from_env())
     models.Session.configure(bind=engine)
     return models.Session
Пример #2
0
        All filenames prefixed with `_` are identified as special packages
        and are ignored by the system.
        """
        filepath = event.pathname
        if not os.path.basename(filepath).startswith("_"):
            if not zipfile.is_zipfile(filepath):
                logger.info("Invalid zipfile: %s" % filepath)
                return None

            self.monitor.trigger_event(filepath)


if __name__ == "__main__":
    # App bootstrapping:
    # Setting up the app configuration, logging and SqlAlchemy Session.
    config = utils.balaio_config_from_env()
    utils.setup_logging()
    models.Session.configure(bind=models.create_engine_from_config(config))

    # Setting up PyInotify event watcher.
    wm = pyinotify.WatchManager()
    handler = EventHandler(config=config)
    notifier = pyinotify.Notifier(wm, handler)

    wm.add_watch(
        config.get("monitor", "watch_path").split(","),
        mask,
        rec=config.getboolean("monitor", "recursive"),
        auto_add=config.getboolean("monitor", "recursive"),
    )
Пример #3
0
    # setting up the required environment variables
    setenv('BALAIO_SETTINGS_FILE', args.configfile)
    if args.alembic_configfile:
        setenv('BALAIO_ALEMBIC_SETTINGS_FILE', args.alembic_configfile)

    activity = args.activity
    if activity == 'syncdb':
        # Creates all database basic structure including
        # Alembic's migration bootstrapping.

        if not args.alembic_configfile:
            sys.exit('%s: error: argument --alembic-config is required' % __file__)

        logger.info('The database infrastructure will be created')
        config = utils.balaio_config_from_env()
        engine = models.create_engine_from_config(config)
        models.init_database(engine)

        print 'Done. All databases had been created'
        sys.exit(0)

    elif activity == 'shell':
        # Places de user on an interactive shell, with a
        # pre-configured Session object.
        local_scope = {}

        def Session_factory():
            engine = models.create_engine_from_config(
                utils.balaio_config_from_env())
            models.Session.configure(bind=engine)