diff --git a/PowerDiagram.py b/PowerDiagram.py index bccaa64..0dd959a 100644 --- a/PowerDiagram.py +++ b/PowerDiagram.py @@ -14,6 +14,7 @@ import re import sys import pygraphviz + def add_capacity_constraints(capacity1, capacity2): """ combines 2 capacity constraints (max amperes) together @@ -63,8 +64,8 @@ def mysql_to_sqlite( mysql_sql_code ): def insertvals_replacer(match): insert, values = match.groups() - #print("insert=%s"%insert) - #print("values=%s"%values) + # print("insert=%s"%insert) + # print("values=%s"%values) values = re.sub('^\s*\(' ,'', values) values = re.sub('\)\s*$' ,'', values) replacement = '' @@ -112,7 +113,7 @@ class Machine(object): power_consumption = self.power_consumption for conn in self.get_outgoing_connections(): power_consumption += conn.get_power_consumption() - print("machine %s : power_consumption += %f" % (self.name, conn.get_power_consumption())) + # print("machine %s : power_consumption += %f" % (self.name, conn.get_power_consumption())) return power_consumption @@ -242,15 +243,16 @@ class PowerConfig(object): rows = cur.fetchall() if len(rows) > 0: plug_type = rows[0][0] - print('plug_type : %s' % plug_type) + # print('plug_type : %s' % plug_type) plug_capacity = get_plug_type_attr(cur, plug_type, 'max_amps') - if plug_capacity: - print('plug_capacity : %f A' % plug_capacity) + #if plug_capacity: + # print('plug_capacity : %f A' % plug_capacity) return plug_capacity - - sqliteDbPath='./simpa.db' + sqliteDbPath=':memory:' # sqlite-specific special name for a file stored in memory. We could use something like '/tmp/simpadb.sqlite' here but this would make parsing really slow (1 minute instead of 1s), unless either : + # - proper fix : group of INSERT statements are surrounded by BEGIN and COMMIT (see http://stackoverflow.com/questions/4719836/python-and-sqlite3-adding-thousands-of-rows) + # - the file is stored on a solid state disk try: os.remove(sqliteDbPath) except: @@ -293,7 +295,7 @@ class PowerConfig(object): if re.match('simpatix.._..', machine_name): machine_name = '_'.join(machine_name.split('_')[0:-1]) - print(machine_name) + # print(machine_name) machine_spec_id = machine_name_toMachine_spec_id(cur, machine_name) if machine_spec_id is not None: @@ -364,7 +366,7 @@ def power_config_to_svg( power_config, svg_file_path ): #graph.add_edge(u'a',u'b',color='blue') #graph.add_edge(u'b',u'a',color='blue') for con in power_config.connections: - print(con.from_plug.machine.name, con.to_plug.machine.name) + # print(con.from_plug.machine.name, con.to_plug.machine.name) if not con.is_redundancy_cable(): # don't display redundancy cables, as they might overlap and hide the main one power_consumption = con.get_power_consumption() amperes = power_consumption/220.0