示例#1
0
        """
        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"),
    )

    logger.info("Watching %s" % config.get("monitor", "watch_path"))
示例#2
0
    parser.add_argument('-c',
                        action='store',
                        dest='configfile',
                        required=False)

    args = parser.parse_args()

    # The user may specify a config file, or use the default
    # specified at `BALAIO_SETTINGS_FILE` env var.
    if args.configfile:
        config = utils.Configuration.from_file(args.configfile)
    else:
        config = utils.balaio_config_from_env()

    # Setting up SqlAlchemy engine.
    engine = models.create_engine_from_config(config)

    # Bootstrapping the app and the server.
    app = httpd.main(config, engine)
    listening = config.get('http_server', 'ip')
    port = config.getint('http_server', 'port')
    server = make_server(listening, port, app)

    print "HTTP Server started listening %s on port %s" % (listening, port)
    try:
        server.serve_forever()
    except KeyboardInterrupt:
        sys.exit('HTTP server stopped.')
else:

    # Setting up the application entry point
示例#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)
            return models.Session
示例#4
0
 def Session_factory():
     engine = models.create_engine_from_config(
         utils.balaio_config_from_env())
     models.Session.configure(bind=engine)
     return models.Session
示例#5
0
        """
        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'))

    logger.info('Watching %s' % config.get('monitor', 'watch_path'))

    notifier.loop()