Skip to content

Commit

Permalink
Merge pull request #20 from makermelissa/main
Browse files Browse the repository at this point in the history
Added kernel userspace mismatch check and updated pre-commit config
  • Loading branch information
makermelissa committed May 26, 2023
2 parents 3b6984a + 205d2fa commit 478b164
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
45 changes: 34 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions adafruit_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 478b164

Please sign in to comment.