Skip to content

Commit

Permalink
Remove the blacklist file loop (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
NikOverflow authored Mar 1, 2024
2 parents dba83e4 + fbe854c commit f11ecfc
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ def is_running():
global process_blacklist
if process_blacklist is not None:
for process in psutil.process_iter():
for name in process_blacklist:
if process.name() == name.strip():
print(f"Blacklisted process '{name.strip()}' detected!")
return True
if process.name() in process_blacklist:
print(f"Blacklisted process '{process.name()}' detected!")
return True
return False

argument_parser = argparse.ArgumentParser()
Expand All @@ -51,7 +50,7 @@ def is_running():
else:
try:
process_blacklist_file = open(arguments.blacklist, "r")
process_blacklist = set(process_blacklist_file.readlines())
process_blacklist = set(line.strip() for line in process_blacklist_file.readlines())
print(f"Blacklist '{arguments.blacklist}' loaded.")
except Exception:
print(f"File '{arguments.blacklist}' not found or no permission!")
Expand Down

0 comments on commit f11ecfc

Please sign in to comment.