mirror of https://github.com/Desuuuu/klipper.git
buildcommands: Convert to Python3 string encoding
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
8714282570
commit
1717263b5a
|
@ -283,7 +283,8 @@ class HandleCommandGeneration:
|
|||
def create_message_ids(self):
|
||||
# Create unique ids for each message type
|
||||
msgid = max(self.msg_to_id.values())
|
||||
for msgname in self.commands.keys() + [m for n, m in self.encoders]:
|
||||
mlist = list(self.commands.keys()) + [m for n, m in self.encoders]
|
||||
for msgname in mlist:
|
||||
msg = self.messages_by_name.get(msgname, msgname)
|
||||
if msg not in self.msg_to_id:
|
||||
msgid += 1
|
||||
|
@ -546,17 +547,17 @@ class HandleIdentify:
|
|||
|
||||
# Write data dictionary
|
||||
if options.write_dictionary:
|
||||
f = open(options.write_dictionary, 'wb')
|
||||
f = open(options.write_dictionary, 'w')
|
||||
f.write(datadict)
|
||||
f.close()
|
||||
|
||||
# Format compressed info into C code
|
||||
zdatadict = zlib.compress(datadict, 9)
|
||||
zdatadict = bytearray(zlib.compress(datadict.encode(), 9))
|
||||
out = []
|
||||
for i in range(len(zdatadict)):
|
||||
if i % 8 == 0:
|
||||
out.append('\n ')
|
||||
out.append(" 0x%02x," % (ord(zdatadict[i]),))
|
||||
out.append(" 0x%02x," % (zdatadict[i],))
|
||||
fmt = """
|
||||
const uint8_t command_identify_data[] PROGMEM = {%s
|
||||
};
|
||||
|
@ -595,7 +596,7 @@ def main():
|
|||
|
||||
# Parse request file
|
||||
ctr_dispatch = { k: v for h in Handlers for k, v in h.ctr_dispatch.items() }
|
||||
f = open(incmdfile, 'rb')
|
||||
f = open(incmdfile, 'r')
|
||||
data = f.read()
|
||||
f.close()
|
||||
for req in data.split('\n'):
|
||||
|
@ -609,7 +610,7 @@ def main():
|
|||
|
||||
# Write output
|
||||
code = "".join([FILEHEADER] + [h.generate_code(options) for h in Handlers])
|
||||
f = open(outcfile, 'wb')
|
||||
f = open(outcfile, 'w')
|
||||
f.write(code)
|
||||
f.close()
|
||||
|
||||
|
|
Loading…
Reference in New Issue