just fixed pylint warnings and errors
This commit is contained in:
parent
160bc22c3d
commit
82816e5193
|
@ -95,7 +95,6 @@ class Machine(object):
|
||||||
return self.name == 'edf' or re.match('^ups[0-9]*$', self.name)
|
return self.name == 'edf' or re.match('^ups[0-9]*$', self.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Plug(object):
|
class Plug(object):
|
||||||
"""
|
"""
|
||||||
represents a power plug (input or output) of a device
|
represents a power plug (input or output) of a device
|
||||||
|
@ -145,6 +144,7 @@ class Plug(object):
|
||||||
|
|
||||||
return capacity
|
return capacity
|
||||||
|
|
||||||
|
|
||||||
class Connection(object):
|
class Connection(object):
|
||||||
"""
|
"""
|
||||||
a power cable connecting an input power plug to an output power plug
|
a power cable connecting an input power plug to an output power plug
|
||||||
|
@ -217,6 +217,7 @@ class Connection(object):
|
||||||
power_consumption = to_machine.get_power_consumption(worst_case_scenario) / num_input_cables
|
power_consumption = to_machine.get_power_consumption(worst_case_scenario) / num_input_cables
|
||||||
return power_consumption
|
return power_consumption
|
||||||
|
|
||||||
|
|
||||||
class PowerConfig(object):
|
class PowerConfig(object):
|
||||||
"""
|
"""
|
||||||
the description of how machines are connected together (in terms of electric power)
|
the description of how machines are connected together (in terms of electric power)
|
||||||
|
@ -289,7 +290,6 @@ class PowerConfig(object):
|
||||||
if power_consumption is not None:
|
if power_consumption is not None:
|
||||||
machine.power_consumption = power_consumption
|
machine.power_consumption = power_consumption
|
||||||
|
|
||||||
|
|
||||||
def get_connection_to(self, to_plug):
|
def get_connection_to(self, to_plug):
|
||||||
for connection in self.connections:
|
for connection in self.connections:
|
||||||
if connection.to_plug == to_plug:
|
if connection.to_plug == to_plug:
|
||||||
|
@ -321,6 +321,7 @@ class PowerConfig(object):
|
||||||
s += str(c) + '\n'
|
s += str(c) + '\n'
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
class CableColorer(object):
|
class CableColorer(object):
|
||||||
|
|
||||||
def get_cable_color(self, cable, worst_case_scenario):
|
def get_cable_color(self, cable, worst_case_scenario):
|
||||||
|
@ -329,6 +330,7 @@ class CableColorer(object):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class SimpleColorer(CableColorer):
|
class SimpleColorer(CableColorer):
|
||||||
|
|
||||||
def get_cable_color(self, cable, worst_case_scenario):
|
def get_cable_color(self, cable, worst_case_scenario):
|
||||||
|
@ -349,6 +351,7 @@ class SimpleColorer(CableColorer):
|
||||||
color = '/svg/green'
|
color = '/svg/green'
|
||||||
return color
|
return color
|
||||||
|
|
||||||
|
|
||||||
class RampColorer(CableColorer):
|
class RampColorer(CableColorer):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -384,6 +387,7 @@ class RampColorer(CableColorer):
|
||||||
color = '/svg/red' # draw overloaded cables in red
|
color = '/svg/red' # draw overloaded cables in red
|
||||||
return color
|
return color
|
||||||
|
|
||||||
|
|
||||||
def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
||||||
"""
|
"""
|
||||||
creates a svg diagram representing the input power configuration
|
creates a svg diagram representing the input power configuration
|
||||||
|
@ -402,7 +406,6 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
||||||
graph.edge_attr['fontsize'] = 10 # default : 14 pt
|
graph.edge_attr['fontsize'] = 10 # default : 14 pt
|
||||||
graph.edge_attr['len'] = 1.5 # default : 1.0
|
graph.edge_attr['len'] = 1.5 # default : 1.0
|
||||||
|
|
||||||
|
|
||||||
# graph.add_node('a')
|
# graph.add_node('a')
|
||||||
# graph.add_node('b')
|
# graph.add_node('b')
|
||||||
# graph.add_edge(u'a',u'b',color='blue')
|
# graph.add_edge(u'a',u'b',color='blue')
|
||||||
|
@ -438,7 +441,6 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
||||||
</tr>\
|
</tr>\
|
||||||
</table>>' % (machine.name, machine_total_power_consumption)
|
</table>>' % (machine.name, machine_total_power_consumption)
|
||||||
|
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
x = 0.0
|
x = 0.0
|
||||||
for rack in racks.itervalues():
|
for rack in racks.itervalues():
|
||||||
|
@ -485,6 +487,5 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
||||||
with open('./toto.dot', 'w') as f:
|
with open('./toto.dot', 'w') as f:
|
||||||
f.write(graph.string())
|
f.write(graph.string())
|
||||||
|
|
||||||
|
|
||||||
graph.layout(prog='dot')
|
graph.layout(prog='dot')
|
||||||
graph.draw(svg_file_path)
|
graph.draw(svg_file_path)
|
||||||
|
|
|
@ -48,7 +48,7 @@ class Inventory(object):
|
||||||
def machine_name_to_machine_spec_id(self, machine_name):
|
def machine_name_to_machine_spec_id(self, machine_name):
|
||||||
try:
|
try:
|
||||||
machine_spec_id = self._sql_reader.get_table_attr('machines', 'name', machine_name, 'machine_spec_id')
|
machine_spec_id = self._sql_reader.get_table_attr('machines', 'name', machine_name, 'machine_spec_id')
|
||||||
except SimpaDbUtil.TableAttrNotFound as e: # @UnusedVariable
|
except SimpaDbUtil.TableAttrNotFound as e: # noqa: F841 @UnusedVariable
|
||||||
raise MachineSpecIdNotFound(machine_name)
|
raise MachineSpecIdNotFound(machine_name)
|
||||||
if machine_spec_id == '':
|
if machine_spec_id == '':
|
||||||
raise MachineSpecIdNotFound(machine_name)
|
raise MachineSpecIdNotFound(machine_name)
|
||||||
|
@ -59,7 +59,7 @@ class Inventory(object):
|
||||||
def machine_spec_id_to_power_consumption(self, machine_spec_id):
|
def machine_spec_id_to_power_consumption(self, machine_spec_id):
|
||||||
try:
|
try:
|
||||||
power_consumption = float(self._sql_reader.get_table_attr('machine_spec_to_power_consumption', 'machine_spec_id', machine_spec_id, 'power_consumption'))
|
power_consumption = float(self._sql_reader.get_table_attr('machine_spec_to_power_consumption', 'machine_spec_id', machine_spec_id, 'power_consumption'))
|
||||||
except SimpaDbUtil.TableAttrNotFound as e: # @UnusedVariable
|
except SimpaDbUtil.TableAttrNotFound as e: # noqa: F841 @UnusedVariable
|
||||||
# some passive machines such as pdus are not detailed in the machine_spec_to_power_consumption because they don't consume power
|
# some passive machines such as pdus are not detailed in the machine_spec_to_power_consumption because they don't consume power
|
||||||
power_consumption = 0.0
|
power_consumption = 0.0
|
||||||
return power_consumption
|
return power_consumption
|
||||||
|
|
Loading…
Reference in New Issue