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,17 +76,21 @@ class Proc:
:return: list of dictionaries with descriptions of found processes
"""
proc_found = []
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']):
pass
elif find in proc['execpid'] or find in proc['exename'] or \
find in proc['exepath'] or find in proc['cmdline']:
proc_found.append(proc)
if len(proc_found) == 0:
return None
else:
return 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']):
pass
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:
return proc_found
if __name__ == "__main__":