util: Convert to Python3 string encoding

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2020-06-12 10:10:59 -04:00
parent 9ce07921c4
commit b859c11378
1 changed files with 5 additions and 5 deletions

View File

@ -67,7 +67,7 @@ def dump_mcu_build():
# Try to log last mcu config # Try to log last mcu config
dump_file_stats(build_dir, '.config') dump_file_stats(build_dir, '.config')
try: try:
f = open(os.path.join(build_dir, '.config'), 'rb') f = open(os.path.join(build_dir, '.config'), 'r')
data = f.read(32*1024) data = f.read(32*1024)
f.close() f.close()
logging.info("========= Last MCU build config =========\n%s" logging.info("========= Last MCU build config =========\n%s"
@ -77,7 +77,7 @@ def dump_mcu_build():
# Try to log last mcu build version # Try to log last mcu build version
dump_file_stats(build_dir, 'out/klipper.dict') dump_file_stats(build_dir, 'out/klipper.dict')
try: try:
f = open(os.path.join(build_dir, 'out/klipper.dict'), 'rb') f = open(os.path.join(build_dir, 'out/klipper.dict'), 'r')
data = f.read(32*1024) data = f.read(32*1024)
f.close() f.close()
data = json.loads(data) data = json.loads(data)
@ -96,7 +96,7 @@ def dump_mcu_build():
def get_cpu_info(): def get_cpu_info():
try: try:
f = open('/proc/cpuinfo', 'rb') f = open('/proc/cpuinfo', 'r')
data = f.read() data = f.read()
f.close() f.close()
except (IOError, OSError) as e: except (IOError, OSError) as e:
@ -130,10 +130,10 @@ def get_git_version(from_file=True):
ver, err = process.communicate() ver, err = process.communicate()
retcode = process.wait() retcode = process.wait()
if retcode == 0: if retcode == 0:
return ver.strip() return ver.strip().decode()
else: else:
logging.debug("Error getting git version: %s", err) logging.debug("Error getting git version: %s", err)
except OSError: except:
logging.debug("Exception on run: %s", traceback.format_exc()) logging.debug("Exception on run: %s", traceback.format_exc())
if from_file: if from_file: