add search 'TypeError' error handling

This commit is contained in:
PavelMuhortov 2021-06-17 08:59:01 +03:00
parent 0e00c42827
commit a69bf7e6a0

View File

@ -76,6 +76,7 @@ class Proc:
:return: list of dictionaries with descriptions of found processes
"""
proc_found = []
try:
for proc in cls.list():
if exclude and (exclude in proc['execpid'] or exclude in proc['exename'] or
exclude in proc['exepath'] or exclude in proc['cmdline']):
@ -83,6 +84,9 @@ class Proc:
elif find in proc['execpid'] or find in proc['exename'] or \
find in proc['exepath'] or find in proc['cmdline']:
proc_found.append(proc)
except TypeError as ex:
print('ON', platform, 'PLATFORM', 'search ERROR:', ex)
finally:
if len(proc_found) == 0:
return None
else: