def get_blade_command(blade_id, id): session = db.session() with session.begin(): command = session.query(ExecCommand).filter( ExecCommand.id == id).first() if command is None or command.blade_id != blade_id: raise exception.NotFound() return _command_to_dict(command)
def findOne(filter): session = db.session() try: with session.begin(): user = session.query(User).filter(filter).one() session.expunge(user) return user except NoResultFound as e: raise exception.NotFound()
def delete_single_device(bus_id, address): for device in read_single_bus(bus_id)['devices']: if device['address'] == address: session = db.session() with session.begin(): i2cConfig = _read_config(session) i2cConfig['i2c_power_read_bus'].value = '' i2cConfig['i2c_power_read_address'].value = '' return raise exception.NotFound()
def read_single_bus(id): i2cConfig = _read_config() for bus in read_bus(): if bus['id'] == id: return bus raise exception.NotFound()
def read_single_device(bus_id, address): for device in read_single_bus(bus_id)['devices']: if device['address'] == address: return device raise exception.NotFound()
def _get_blade(id, session): blade = session.query(Blade).filter(Blade.id == id).first() if blade is None: raise exception.NotFound() return blade