def __init__(self, file_name, connection_args, actions=None): self.file_name = file_name self.engine, self.session = db.init(**connection_args) if actions: self.actions = [self.all_actions[i - 1] for i in actions] else: self.actions = self.all_actions
def bycycle(config, service, q): """Run a bycycle service""" module_name = 'bycycle.core.service.{service}'.format(service=service) service_factory = load_object(module_name, 'Service') if service == 'route': q = re.split('\s+to\s+', q, re.I) if len(q) < 2: abort(1, 'Route must be specified as "A to B"') _, session_factory = db.init() session = session_factory() start_time = time.time() try: service = service_factory(session) response = service.query(q) except Exception: session.rollback() raise else: session.close() print(response) print('{:.2f} seconds'.format(time.time() - start_time))
def setUp(self): self.engine, self.session_factory = db.init() self.session = self.session_factory()
def __init__(self, connection_args, clean=True): self.engine, self.session = db.init(**connection_args) self.clean = clean