From 205d2faf9d6f015a08c8020ddfbabb53a171ad4c Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Fri, 26 May 2023 09:12:15 -0700 Subject: [PATCH] Added kernel userspace mismatch check and updated precommit config --- .pre-commit-config.yaml | 45 +++++++++++++++++++++++++++++++---------- adafruit_shell.py | 17 ++++++++++++++++ 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5fc6e2e..70ade69 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,17 +3,40 @@ # SPDX-License-Identifier: Unlicense repos: -- repo: https://github.com/python/black - rev: 22.3.0 + - repo: https://github.com/python/black + rev: 23.3.0 hooks: - - id: black -- repo: https://github.com/fsfe/reuse-tool - rev: v0.12.1 + - id: black + - repo: https://github.com/fsfe/reuse-tool + rev: v1.1.2 hooks: - - id: reuse -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + - id: reuse + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - repo: https://github.com/pycqa/pylint + rev: v2.17.4 + hooks: + - id: pylint + name: pylint (library code) + types: [python] + args: + - --disable=consider-using-f-string + exclude: "^(docs/|examples/|tests/|setup.py$)" + - id: pylint + name: pylint (example code) + description: Run pylint rules on "examples/*.py" files + types: [python] + files: "^examples/" + args: + - --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code + - id: pylint + name: pylint (test code) + description: Run pylint rules on "tests/*.py" files + types: [python] + files: "^tests/" + args: + - --disable=missing-docstring,consider-using-f-string,duplicate-code diff --git a/adafruit_shell.py b/adafruit_shell.py index 8e813ae..681af4f 100644 --- a/adafruit_shell.py +++ b/adafruit_shell.py @@ -36,6 +36,7 @@ __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_Python_Shell.git" + # pylint: disable=too-many-public-methods class Shell: """ @@ -563,6 +564,22 @@ def check_kernel_update_reboot_required(self): ) self.prompt_reboot() + def check_kernel_userspace_mismatch(self): + """ + Check if the userspace is 64-bit and kernel is 32-bit + """ + if self.is_arm64() and platform.architecture()[0] == "32bit": + print( + "Unable to compile driver because kernel space is 64-bit, but user space is 32-bit." + ) + if self.is_raspberry_pi_os() and self.prompt( + "Add parameter to /boot/config.txt to use 32-bit kernel?" + ): + self.reconfig("/boot/config.txt", "^.*arm_64bit.*$", "arm_64bit=0") + self.prompt_reboot() + else: + self.bail("Unable to continue while mismatch is present.") + # pylint: enable=invalid-name def is_raspberry_pi_os(self):