[Pymoul-svn] SF.net SVN: pymoul: [250] enumprocess/trunk
Status: Alpha
Brought to you by:
tiran
From: <ti...@us...> - 2007-03-13 15:32:00
|
Revision: 250 http://pymoul.svn.sourceforge.net/pymoul/?rev=250&view=rev Author: tiran Date: 2007-03-13 08:32:00 -0700 (Tue, 13 Mar 2007) Log Message: ----------- Go to v0.1.1. Fixed more issues in PsReader Modified Paths: -------------- enumprocess/trunk/CHANGES.txt enumprocess/trunk/setup.py enumprocess/trunk/src/enumprocess/processinfo.py enumprocess/trunk/version.txt Modified: enumprocess/trunk/CHANGES.txt =================================================================== --- enumprocess/trunk/CHANGES.txt 2007-03-13 15:09:57 UTC (rev 249) +++ enumprocess/trunk/CHANGES.txt 2007-03-13 15:32:00 UTC (rev 250) @@ -0,0 +1,5 @@ +0.1.1 +----- + + * BSD and Mac compatibility of PsReader + Modified: enumprocess/trunk/setup.py =================================================================== --- enumprocess/trunk/setup.py 2007-03-13 15:09:57 UTC (rev 249) +++ enumprocess/trunk/setup.py 2007-03-13 15:32:00 UTC (rev 250) @@ -21,7 +21,7 @@ from setuptools import setup from setuptools import find_packages -VERSION = "0.1" +VERSION = "0.1.1" me = "Christian Heimes" email = "chr...@ch..." Modified: enumprocess/trunk/src/enumprocess/processinfo.py =================================================================== --- enumprocess/trunk/src/enumprocess/processinfo.py 2007-03-13 15:09:57 UTC (rev 249) +++ enumprocess/trunk/src/enumprocess/processinfo.py 2007-03-13 15:32:00 UTC (rev 250) @@ -61,7 +61,7 @@ >>> getPidDetails('self')['name'] == getPidDetails(cur)['name'] True ->>> getPidDetails(cur)['name'] == mapping[cur] +>>> getPidDetails(cur)['name'] == mapping[cur] or getPidDetails(cur)['name'] True >>> for impl in (WinEnumProcesses(), LinuxProcReader(), PsParser()): @@ -155,9 +155,10 @@ # -e: every process # -w twice: unlimited width # -O: format - CMD = "ps -e -w -w" - PIDNAMES = "%s -O pid,ucmd" % CMD - PIDS = "%s -O pid" % CMD + CMD = "ps" + PIDNAMES = CMD + " -e -o pid,ucmd" + PIDS = CMD + " -e -o pid" + PIDDETAILS = CMD + " -p %i -o ucmd" @classmethod def supported(cls): @@ -178,11 +179,11 @@ def getPids(cls): """Get a list of pids """ - stdout = cls._exec(cls.PIDS) - if stdout is None: + lines = cls._exec(cls.PIDS) + if not lines: return None pids = [] - for line in stdout: + for line in lines: try: pid = int(line.strip()) except ValueError: @@ -195,11 +196,11 @@ def getPidNames(cls): """Get a list of pid -> name """ - stdout = cls._exec(cls.PIDNAMES) - if stdout is None: + lines = cls._exec(cls.PIDNAMES) + if not lines: return None mapping = {} - for line in stdout: + for line in lines: line = line.strip() idx = line.find(' ') pid, name = line[:idx], line[idx+1:] @@ -219,7 +220,8 @@ """ if pid == 'self': pid = os.getpid() - raise UnsupportedError("not implemented yet") + lines = cls._exec(cls.PIDDETAILS % pid) + return {'name' : lines[0].strip()} @staticmethod def _exec(cmd): @@ -244,7 +246,10 @@ LOG.error("'%s' returned with error code %i" % (cmd, rc)) return None else: - return popen.stdout + lines = popen.stdout.readlines() + if 'PID' in lines[0] or 'CMD' in lines[0]: + lines.pop(0) + return lines class LinuxProcReader(object): """Get process informations under Linux by reading /proc Modified: enumprocess/trunk/version.txt =================================================================== --- enumprocess/trunk/version.txt 2007-03-13 15:09:57 UTC (rev 249) +++ enumprocess/trunk/version.txt 2007-03-13 15:32:00 UTC (rev 250) @@ -1 +1 @@ -0.1 \ No newline at end of file +0.1.1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |