diff --git a/adafruit_shell.py b/adafruit_shell.py index f5c7ef1..c90149c 100644 --- a/adafruit_shell.py +++ b/adafruit_shell.py @@ -88,7 +88,7 @@ class Shell: if not suppress_message: self.info(decoded_output) full_output += decoded_output - except Exception as err: # pylint: disable=broad-except + except Exception: # pylint: disable=broad-except pass finally: sys.stdout = original_stdout @@ -294,7 +294,7 @@ class Shell: if self.exists(location) and not self.isdir(location): if multi_line: - with open(location, "r+") as file: + with open(location, "r+", encoding="utf-8") as file: if re.search(pattern, file.read(), flags=re.DOTALL): found = True else: @@ -315,7 +315,7 @@ class Shell: if self.pattern_search(location, pattern, multi_line): if multi_line: regex = re.compile(pattern, flags=re.DOTALL) - with open(location, "r+") as file: + with open(location, "r+", encoding="utf-8") as file: data = file.read() file.seek(0) file.write(regex.sub(replace, data)) @@ -397,7 +397,7 @@ class Shell: content = "\n" + content else: mode = "w" - with open(self.path(path), mode) as service_file: + with open(self.path(path), mode, encoding="utf-8") as service_file: service_file.write(content) @staticmethod @@ -441,6 +441,13 @@ class Shell: """ return platform.machine() == "armv8l" + @staticmethod + def is_arm64(): + """ + Check if Platform.machine() returns ARM 64 + """ + return platform.machine() == "aarch64" + @staticmethod def get_arch(): """Return a string containing the architecture""" @@ -461,15 +468,17 @@ class Shell: ) release = None if os.path.exists("/etc/os-release"): - with open("/etc/os-release") as f: + with open("/etc/os-release", encoding="utf-8") as f: if "Raspbian" in f.read(): release = "Raspbian" if self.run_command("command -v apt-get", suppress_message=True): - with open("/etc/os-release") as f: + with open("/etc/os-release", encoding="utf-8") as f: release_file = f.read() for opsys in os_releases: if opsys in release_file: release = opsys + if release == "Debian" and os.path.exists("/etc/rpi-issue"): + release = "Raspbian" if os.path.isdir(os.path.expanduser("~/.kano-settings")) or os.path.isdir( os.path.expanduser("~/.kanoprofile") ): @@ -486,7 +495,7 @@ class Shell: return None raspbian_releases = ("buster", "stretch", "jessie", "wheezy") if os.path.exists("/etc/os-release"): - with open("/etc/os-release") as f: + with open("/etc/os-release", encoding="utf-8") as f: release_file = f.read() if "/sid" in release_file: return "unstable"