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
if attempts_checkout: checkout_lst = CheckoutList() try: for attempt in attempts_checkout: checkout_lst.append((attempt, client, conn)) #Execute the checkout procedure for each item pool.map(checkout_procedure, checkout_lst) transaction.commit() except: transaction.abort() raise time.sleep(config.getint('checkout', 'mins_to_wait') * 60) pool.close if __name__ == '__main__': config = utils.balaio_config_from_env() utils.setup_logging(config) models.Session.configure(bind=models.create_engine_from_config(config)) print('Start checkout process...') main(config)
filepath = event.pathname if not os.path.basename(filepath).startswith('_'): if not zipfile.is_zipfile(filepath): logger.info('Invalid zipfile: %s.' % filepath) return None logger.debug('Adding %s to checkin processing pool.' % filepath) self.pool.add_job(filepath) if __name__ == '__main__': # App bootstrapping: # Setting up the app configuration, logging and SqlAlchemy Session. config = utils.balaio_config_from_env() utils.setup_logging(config) 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()
def Session_factory(): engine = models.create_engine_from_config(config) models.Session.configure(bind=engine) return models.Session