Пример #1
0
 def get_slave(self, slave_id):
     """Get the slave with the given id"""
     with self._lock:
         if slave_id in self._slaves:
             return self._slaves[slave_id]
         else:
             raise MissingKeyError("Slave {0} doesn't exist".format(slave_id))
Пример #2
0
 def remove_slave(self, slave_id):
     """Remove the slave with the given id"""
     with self._lock:
         if slave_id in self._slaves:
             self._slaves.pop(slave_id)
         else:
             raise MissingKeyError("Slave {0} already exists".format(slave_id))
Пример #3
0
 def _get_block(self, block_name):
     """Find a block by its name and raise and exception if not found"""
     if block_name not in self._blocks:
         raise MissingKeyError("block {0} not found".format(block_name))
     (block_type, starting_address) = self._blocks[block_name]
     for block in self._memory[block_type]:
         if block.starting_address == starting_address:
             return block
     raise Exception("Bug?: the block {0} is not registered properly in memory".format(block_name))