From 6628c638afd3e4cb30ff440fb15096516f15268b Mon Sep 17 00:00:00 2001 From: anima Date: Thu, 27 Feb 2025 23:02:23 +0100 Subject: [PATCH] fix regex for device search --- checks/check_airq.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/checks/check_airq.py b/checks/check_airq.py index e4586e4..e55d037 100755 --- a/checks/check_airq.py +++ b/checks/check_airq.py @@ -103,7 +103,7 @@ class AirQ: matches = list() # log has con is the log entry rolls out command = ["journalctl", "-k", "--no-pager"] # alternative: dmesg # maybe usefull lsusb - pattern = re.compile(r'hidraw\d{2}') + pattern = re.compile(r'hidraw\d{1,2}') ## get kernel logs result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) if result.returncode != 0: @@ -121,9 +121,9 @@ class AirQ: ## search in found log line the usb name and verify path exists if len(matches) > 0: dev_path = f'/dev/{matches[0]}' - if path.exists(f'/dev/{matches[0]}'): - logging.debug(f'usb device is in /dev/{matches[0]}') - self.device = f'/dev/{matches[0]}' + if path.exists(dev_path): + logging.debug(f'usb device is under path {dev_path}') + self.device = dev_path return True logging.error(f'usb device not found!') return False