Package moul :: Package osdependent :: Module processinfo
[hide private]
[frames] | no frames]

Module processinfo



Get process informations

API

getPids() - list of ints/longs getPidNames() - mapping pid -> name getPidDetails(pid) - detailed informations about a process getPidDetails('self') - detailed informations about current process
>>> cur = os.getpid()
>>> exe = sys.executable
>>> pids = getPids()
>>> pids > 1
True
>>> isinstance(pids[0], (int, long))
True
>>> cur in pids
True
>>> mapping = getPidNames()
>>> cur in mapping
True
>>> mapping[cur].lower() in sys.executable
True
>>> getPidDetails('self')['name'] == getPidDetails(cur)['name']
True
>>> getPidDetails(cur)['name'] == mapping[cur]
True


Classes [hide private]
  LinuxProcReader
Get process informations under Linux by reading /proc
  WinEnumProcesses
""Get process informations under Win32 with psapi.dll

Functions [hide private]
  _plat(S, prefix, start=..., end=...)
Return True if S starts with the specified prefix, False otherwise.
  getPids()
Get a list of pids
  getPidNames()
Get a list of pid -> name
  getPidDetails(pid)
Get detailed informations about a process

Variables [hide private]
  __author__ = 'Christian Heimes'
  __version__ = '$Id: processinfo.py 125 2007-02-02 17:59:04Z tiran $'
  __revision__ = '$Revision: 125 $'
  LOG = <logging.Logger instance at 0x403084ec>
  PLAT = 'linux'
  PSAPI = windll.psapi
  KERNEL = windll.kernel32
  PROCESS_QUERY_INFORMATION = 0x0400
  PROCESS_VM_READ = 0x0010
  PROCESS_FLAGS = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ
  NULL = '\x00'
  _enumProcesses = <moul.osdependent.processinfo.LinuxProcReader object...

Function Details [hide private]

_plat(S, prefix, start=..., end=...)

 
Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.
Returns:
bool

getPids()

 
Get a list of pids

getPidNames()

 
Get a list of pid -> name

getPidDetails(pid)

 
Get detailed informations about a process

Variables Details [hide private]

__author__

None
Value:
'Christian Heimes'                                                     
      

__version__

None
Value:
'$Id: processinfo.py 125 2007-02-02 17:59:04Z tiran $'                 
      

__revision__

None
Value:
'$Revision: 125 $'                                                     
      

LOG

None
Value:
<logging.Logger instance at 0x403084ec>                                
      

PLAT

None
Value:
'linux'                                                                
      

PSAPI

None
Value:
windll.psapi                                                           
      

KERNEL

None
Value:
windll.kernel32                                                        
      

PROCESS_QUERY_INFORMATION

None
Value:
0x0400                                                                 
      

PROCESS_VM_READ

None
Value:
0x0010                                                                 
      

PROCESS_FLAGS

None
Value:
PROCESS_QUERY_INFORMATION | PROCESS_VM_READ                            
      

NULL

None
Value:
'\x00'                                                                 
      

_enumProcesses

None
Value:
<moul.osdependent.processinfo.LinuxProcReader object at 0x403085ec>