diff --git a/inventory.py b/inventory.py index 4d3a4e7..a8c0913 100644 --- a/inventory.py +++ b/inventory.py @@ -49,6 +49,8 @@ class Inventory(object): machine_spec_id = self._sql_reader.get_table_attr('machines', 'name', machine_name, 'machine_spec_id') except SimpaDbUtil.TableAttrNotFound as e: # @UnusedVariable raise MachineSpecIdNotFound(machine_name) + if machine_spec_id == '': + raise MachineSpecIdNotFound(machine_name) return machine_spec_id # electricity related methods @@ -78,9 +80,9 @@ class Inventory(object): machine_spec_id = None try: machine_spec_id = self.machine_name_to_machine_spec_id(machine_name) - except SimpaDbUtil.TableAttrNotFound as e: # @UnusedVariable - raise MachineSpecIdNotFound(machine_name) - if machine_spec_id is not None: + except MachineSpecIdNotFound as e: + raise e + else: # INSERT INTO `powerplug_desc` (`machine_spec_id`, `powerplug_id`, `plug_type`) VALUES # ('atos_mpdu_2901382', 'i', 'iec60309_blue_pne6h_32a_m'), rows = self._sql_reader.query("SELECT plug_type FROM powerplug_desc WHERE machine_spec_id='%s' AND powerplug_id='%s'" % (machine_spec_id, plug_name)) @@ -96,14 +98,15 @@ class Inventory(object): """ plug_capacity = None plug_type = None + try: plug_type = self.get_plug_type(plug.machine.name, plug.name) except MachineSpecIdNotFound: # some machines are not actual machines (eg edf, ups1pdu) pass - except PlugTypeNotFound: + #except PlugTypeNotFound: # some plugs are just plain connections, with no actual plug types - pass + # pass if plug_type is not None: # print('plug_type : %s' % plug_type)