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
|
:return: list of dictionaries with descriptions of found processes
|
||||||
"""
|
"""
|
||||||
proc_found = []
|
proc_found = []
|
||||||
for proc in cls.list():
|
try:
|
||||||
if exclude and (exclude in proc['execpid'] or exclude in proc['exename'] or
|
for proc in cls.list():
|
||||||
exclude in proc['exepath'] or exclude in proc['cmdline']):
|
if exclude and (exclude in proc['execpid'] or exclude in proc['exename'] or
|
||||||
pass
|
exclude in proc['exepath'] or exclude in proc['cmdline']):
|
||||||
elif find in proc['execpid'] or find in proc['exename'] or \
|
pass
|
||||||
find in proc['exepath'] or find in proc['cmdline']:
|
elif find in proc['execpid'] or find in proc['exename'] or \
|
||||||
proc_found.append(proc)
|
find in proc['exepath'] or find in proc['cmdline']:
|
||||||
if len(proc_found) == 0:
|
proc_found.append(proc)
|
||||||
return None
|
except TypeError as ex:
|
||||||
else:
|
print('ON', platform, 'PLATFORM', 'search ERROR:', ex)
|
||||||
return proc_found
|
finally:
|
||||||
|
if len(proc_found) == 0:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return proc_found
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user