add search 'TypeError' error handling
This commit is contained in:
parent
0e00c42827
commit
a69bf7e6a0
26
srchproc.py
26
srchproc.py
|
@ -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__":
|
||||
|
|
Loading…
Reference in New Issue
Block a user