Fix usbguard-notify.py
This commit is contained in:
@ -11,10 +11,7 @@ DUNSTIFY_EXEC_NAME = shutil.which("dunstify")
|
|||||||
open_notifications = {}
|
open_notifications = {}
|
||||||
|
|
||||||
|
|
||||||
def parse_event_type_and_id(stream):
|
def parse_event_type_and_id(line):
|
||||||
line = stream.readline()
|
|
||||||
if not line:
|
|
||||||
return None, True
|
|
||||||
if not line.startswith("[device] "):
|
if not line.startswith("[device] "):
|
||||||
return None, False
|
return None, False
|
||||||
event_type = re.findall("(?<=\\[device\\] )[a-zA-Z]+", line)
|
event_type = re.findall("(?<=\\[device\\] )[a-zA-Z]+", line)
|
||||||
@ -107,12 +104,8 @@ with Popen(
|
|||||||
first_line = (
|
first_line = (
|
||||||
usbguard_proc.stdout.readline()
|
usbguard_proc.stdout.readline()
|
||||||
) # get rid of initial connection message
|
) # get rid of initial connection message
|
||||||
if not first_line:
|
for line in usbguard_proc.stdout:
|
||||||
sys.exit()
|
event_type_result = parse_event_type_and_id(line)
|
||||||
while True:
|
|
||||||
event_type_result, eof = parse_event_type_and_id(usbguard_proc.stdout)
|
|
||||||
if eof:
|
|
||||||
sys.exit()
|
|
||||||
if event_type_result is None:
|
if event_type_result is None:
|
||||||
continue
|
continue
|
||||||
event_type, dev_id = event_type_result
|
event_type, dev_id = event_type_result
|
||||||
|
|||||||
Reference in New Issue
Block a user