Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use regex to parse kernel version #199

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pitopd/poweroff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from distutils.version import StrictVersion
from os.path import isfile
from platform import uname
from re import match
from time import sleep

from pitop.common.common_ids import DeviceID
Expand All @@ -22,8 +22,10 @@ def _do_poweroff_legacy():
request_shutdown = False

def using_old_kernel():
current_version_name = uname().release.split("-")[0]
return StrictVersion(current_version_name) < StrictVersion("5.0.0")
# check if kernel version is lower than "5.0.0"
# to avoid errors when setting cshigh
# https://github.com/raspberrypi/linux/issues/3745
return match(r"^[0-4]\.", uname().release) is not None

def parity7(data):
p = False
Expand Down
8 changes: 5 additions & 3 deletions pitopd/pthub/pthub_spi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import logging
import threading
import traceback
from distutils.version import StrictVersion
from enum import Enum
from platform import uname
from re import match
from time import sleep

from pitop.common.common_ids import DeviceID
Expand Down Expand Up @@ -301,8 +301,10 @@ def _process_spi_resp(self, resp, init=False):
self._state.set_brightness(spi_brightness_int, False)

def __using_old_kernel(self):
current_version_name = uname().release.split("-")[0]
return StrictVersion(current_version_name) < StrictVersion("5.0.0")
# check if kernel version is lower than "5.0.0"
# to avoid errors when setting cshigh
# https://github.com/raspberrypi/linux/issues/3745
return match(r"^[0-4]\.", uname().release) is not None

def _transceive_spi(self, bits_to_send):
hex_str_to_send = "0x" + str(hex(bits_to_send))[2:].zfill(2)
Expand Down
Loading