fix regex for device search

This commit is contained in:
2025-02-27 23:02:23 +01:00
parent 8011d1282f
commit 6628c638af

View File

@@ -103,7 +103,7 @@ class AirQ:
matches = list() matches = list()
# log has con is the log entry rolls out # log has con is the log entry rolls out
command = ["journalctl", "-k", "--no-pager"] # alternative: dmesg # maybe usefull lsusb 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 ## get kernel logs
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
if result.returncode != 0: if result.returncode != 0:
@@ -121,9 +121,9 @@ class AirQ:
## search in found log line the usb name and verify path exists ## search in found log line the usb name and verify path exists
if len(matches) > 0: if len(matches) > 0:
dev_path = f'/dev/{matches[0]}' dev_path = f'/dev/{matches[0]}'
if path.exists(f'/dev/{matches[0]}'): if path.exists(dev_path):
logging.debug(f'usb device is in /dev/{matches[0]}') logging.debug(f'usb device is under path {dev_path}')
self.device = f'/dev/{matches[0]}' self.device = dev_path
return True return True
logging.error(f'usb device not found!') logging.error(f'usb device not found!')
return False return False