beremiz

MQTT: more py2/py3 fixes. Now loads and builds.

11 months ago, Edouard Tisserant
bc39a871d356
Parents 2f8fd3d28168
Children f83075f09e70
MQTT: more py2/py3 fixes. Now loads and builds.
--- a/mqtt/mqtt_client_gen.py Thu Jun 26 16:47:08 2025 +0200
+++ b/mqtt/mqtt_client_gen.py Thu Jun 26 16:48:59 2025 +0200
@@ -280,7 +280,7 @@
if len(self) == 0:
v["Location"] = 0
else:
- iecnums = set(zip(*self)[self.dsc.Location_column])
+ iecnums = set(list(zip(*self))[self.dsc.Location_column])
greatest = max(iecnums)
holes = set(range(greatest)) - iecnums
v["Location"] = min(holes) if holes else greatest+1
@@ -340,12 +340,13 @@
for direction, model in self.items():
self[direction].clear()
for row in reader:
- direction = row[0]
- # avoids calling change callback when loading CSV
- l = self[direction]
- v = l._filter_line(row[1:])
- if v is not None:
- list.append(l,v)
+ if row:
+ direction = row[0]
+ # avoids calling change callback when loading CSV
+ l = self[direction]
+ v = l._filter_line(row[1:])
+ if v is not None:
+ list.append(l,v)
# TODO be verbose in case of malformed CSV
def SaveCSV(self,path):
@@ -363,7 +364,7 @@
def GenerateC(self, name, path, locstr, config, datatype_info_getter):
c_template_filepath = paths.AbsNeighbourFile(__file__, "mqtt_template.c")
- c_template_file = open(c_template_filepath , 'rb')
+ c_template_file = open(c_template_filepath , 'r')
c_template = c_template_file.read()
c_template_file.close()