diff --git a/srchproc.py b/srchproc.py index 3ee56b3..479a8b8 100644 --- a/srchproc.py +++ b/srchproc.py @@ -10,8 +10,8 @@ class Proc: """ Find a running process from Python """ - @staticmethod - def list_windows(): + @classmethod + def _list_windows(cls): """ Find all running process with wmi :return: list of dictionaries with descriptions of found processes @@ -35,8 +35,8 @@ class Proc: execlist.append({'execpid': execpid, 'exename': exename, 'exepath': exepath, 'cmdline': cmdline}) return execlist - @staticmethod - def list_linux(): + @classmethod + def _list_linux(cls): """ Find all running process with ps :return: list of dictionaries with descriptions of found processes @@ -52,23 +52,23 @@ class Proc: execlist.append({'execpid': execpid, 'exename': exename, 'exepath': exepath, 'cmdline': cmdline}) return execlist - @staticmethod - def list(): + @classmethod + def list(cls): """ Find all running process :return: list of dictionaries with descriptions of found processes """ if platform.startswith('linux'): - return Proc.list_linux() + return cls._list_linux() elif platform.startswith('win32'): - return Proc.list_windows() + return cls._list_windows() elif platform.startswith('darwin'): - return Proc.list_linux() + return cls._list_linux() else: return None - @staticmethod - def search(find: str, exclude: str = None): + @classmethod + def search(cls, find: str, exclude: str = None): """ Find specified processes :param find: find process pid, name or arguments @@ -76,7 +76,7 @@ class Proc: :return: list of dictionaries with descriptions of found processes """ proc_found = [] - for proc in Proc.list(): + 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