Skip to content

Commit 8cca552

Browse files
committed
fix: py35 compatibility
1 parent cdd4c98 commit 8cca552

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

checkbox-ng/plainbox/vendor/image_info.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,14 @@ def dcd_string_to_info_iot(dcd_string):
157157

158158

159159
def dcd_info():
160-
if DCD_FILE_IOT.is_file():
161-
dcd_string = DCD_FILE_IOT.read_text().strip()
162-
print(f"Found IoT dcd string: {dcd_string}", file=sys.stderr)
163-
return dcd_string_to_info_iot(dcd_string)
160+
try:
161+
if DCD_FILE_IOT.is_file():
162+
with DCD_FILE_IOT.open("r", encoding="utf-8") as f:
163+
dcd_string = f.read().strip()
164+
print("Found IoT dcd string: {}".format(dcd_string), file=sys.stderr)
165+
return dcd_string_to_info_iot(dcd_string)
166+
except (IOError, OSError):
167+
print("IoT dcd file not found. Assuming PC platform", file=sys.stderr)
164168

165169
ubuntu_report = parse_ubuntu_report()
166170
print(

0 commit comments

Comments
 (0)