From: Shivani Tipnis Date: Mon, 8 Oct 2018 05:02:09 +0000 (+0530) Subject: nvs_part_gen: Update to make python version compatible X-Git-Tag: v3.2-beta1~49^2^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff30a1fbd35a01dfbbbb4bb6420db956f78e002a;p=esp-idf nvs_part_gen: Update to make python version compatible (cherry picked from commit 3506b2d60792e5d4ed4f744b28f2da6733c6aae7) --- diff --git a/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py b/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py index 0f641d6129..a1cc81a657 100755 --- a/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py +++ b/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py @@ -28,6 +28,7 @@ import os import array import csv import zlib +import codecs from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.backends import default_backend @@ -81,9 +82,9 @@ class Page(object): # set page state to active page_header= bytearray(b'\xff')*32 page_state_active_seq = Page.ACTIVE - page_header[0:4] = struct.pack('= Page.PAGE_PARAMS["max_entries"]: raise PageFullError() - entry_struct = bytearray('\xff')*32 + entry_struct = bytearray(b'\xff')*32 entry_struct[0] = ns_index # namespace index entry_struct[2] = 0x01 # Span chunk_index = Page.CHUNK_ANY entry_struct[3] = chunk_index # write key - key_array = bytearray('\x00')*16 + key_array = bytearray(b'\x00')*16 entry_struct[8:24] = key_array - entry_struct[8:8 + len(key)] = key + + if sys.version_info[0] < 3: + entry_struct[8:8 + len(key)] = key + else: + entry_struct[8:8 + len(key)] = key.encode('utf8') + if encoding == "u8": entry_struct[1] = Page.U8 - entry_struct[24] = struct.pack('