diff --git a/gpt_bin/gpt_ini2bin.py b/gpt_bin/gpt_ini2bin.py index 21530563..d73b807e 100755 --- a/gpt_bin/gpt_ini2bin.py +++ b/gpt_bin/gpt_ini2bin.py @@ -3,31 +3,29 @@ import uuid import struct import sys -if sys.version_info < (3, 0, 1): - import ConfigParser -else: - import configparser +import configparser type_2_guid = { -# official guid for gpt partition type + # official guid for gpt partition type 'fat' : 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7', 'esp' : 'c12a7328-f81f-11d2-ba4b-00a0c93ec93b', 'linux' : '0fc63daf-8483-4772-8e79-3d69d8477de4', 'linux-swap' : '0657fd6d-a4ab-43c4-84e5-0933c84b4f4f', 'reserved' : '8da63339-0007-60c0-c436-083ac8230908', -# generated guid for android + # generated guid for android 'bootloader': '2568845D-2332-4675-BC39-8FA5A4748D15', 'boot' : '49a4d17f-93a3-45c1-a0de-f50b2ebe2599', 'recovery' : '4177c722-9e92-4aab-8644-43502bfd5506', 'misc' : 'ef32a33b-a409-486c-9141-9ffb711f6266', 'metadata' : '20ac26be-20b7-11e3-84c5-6cfdb94711e9', 'tertiary' : '767941d0-2085-11e3-ad3b-6cfdb94711e9', - 'factory' : '9fdaa6ef-4b3f-40d2-ba8d-bff16bfb887b' } + 'factory' : '9fdaa6ef-4b3f-40d2-ba8d-bff16bfb887b' +} def zero_pad(s, size): - if (len(s) > size): + if len(s) > size: print('error', len(s)) - s += '\0' * (size - len(s)) + s += b'\0' * (size - len(s)) return s def copy_section(cfg, a, b): @@ -138,10 +136,7 @@ def main(): gpt_in = sys.argv[1] - if sys.version_info < (3, 0, 1): - cfg = ConfigParser.SafeConfigParser() - else: - cfg = configparser.SafeConfigParser(strict=False) + cfg = configparser.ConfigParser(strict=False) cfg.read(gpt_in) @@ -154,7 +149,7 @@ def main(): start_lba = cfg.getint('base', 'start_lba') npart = len(part) - out = sys.stdout + out = sys.stdout.buffer out.write(struct.pack(' - - MTL-NUC - NUC14RVH-B - QUIET - - - cpu_passive - - - x86_pkg_temp - 85000 - Passive - - rapl_limit_1 - - - - x86_pkg_temp - 95000 - Passive - - rapl_limit_2 - - - - - - cpu_critical - - - x86_pkg_temp - 100000 - Critical - - - - - - - rapl_limit_1 - /sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_0_power_limit_uw - 12000000 - 0 - 8000000 - -200000 - - - rapl_limit_2 - /sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_0_power_limit_uw - 8000000 - 0 - 6000000 - -200000 - - -