Added kernel userspace mismatch check and updated precommit config

This commit is contained in:
Melissa LeBlanc-Williams 2023-05-26 09:12:15 -07:00
parent 3b6984a1fe
commit 205d2faf9d
2 changed files with 51 additions and 11 deletions

View file

@ -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

View file

@ -36,6 +36,7 @@ import adafruit_platformdetect
__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 @@ class Shell:
)
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):