Exemplo n.º 1
0
        def list_processes(self):
            """
            Returns information about all running processes (on POSIX systems: using ``ps``)

            .. versionadded:: 1.3
            """
            ps = self["ps"]
            lines = ps("-e", "-o", "pid,uid,stat,args").splitlines()
            lines.pop(0) # header
            for line in lines:
                parts = line.strip().split()
                yield ProcInfo(int(parts[0]), int(parts[1]), parts[2], " ".join(parts[3:]))
Exemplo n.º 2
0
        def list_processes(self):
            """
            Returns information about all running processes (on Windows: using ``tasklist``)

            .. versionadded:: 1.3
            """
            import csv
            tasklist = local["tasklist"]
            lines = tasklist("/V", "/FO", "CSV").encode("utf8").splitlines()
            rows = csv.reader(lines)
            header = rows.next()
            imgidx = header.index('Image Name')
            pididx = header.index('PID')
            statidx = header.index('Status')
            useridx = header.index('User Name')
            for row in rows:
                yield ProcInfo(int(row[pididx]), row[useridx].decode("utf8"), 
                    row[statidx].decode("utf8"), row[imgidx].decode("utf8"))
Exemplo n.º 3
0
        def list_processes(self):
            """
            Returns information about all running processes (on Windows: using ``tasklist``)

            .. versionadded:: 1.3
            """
            import csv

            tasklist = local["tasklist"]
            output = tasklist("/V", "/FO", "CSV")
            lines = output.splitlines()
            rows = csv.reader(lines)
            header = next(rows)
            imgidx = header.index("Image Name")
            pididx = header.index("PID")
            statidx = header.index("Status")
            useridx = header.index("User Name")
            for row in rows:
                yield ProcInfo(int(row[pididx]), row[useridx], row[statidx],
                               row[imgidx])
Exemplo n.º 4
0
        def list_processes(self):
            """
            Returns information about all running processes (on Windows: using ``tasklist``)

            .. versionadded:: 1.3
            """
            import csv
            tasklist = local["tasklist"]
            output = tasklist("/V", "/FO", "CSV")
            if not six.PY3:
                # The Py2 csv reader does not support non-ascii values
                output = output.encode('ascii', 'ignore')
            lines = output.splitlines()
            rows = csv.reader(lines)
            header = next(rows)
            imgidx = header.index('Image Name')
            pididx = header.index('PID')
            statidx = header.index('Status')
            useridx = header.index('User Name')
            for row in rows:
                yield ProcInfo(int(row[pididx]), row[useridx],
                    row[statidx], row[imgidx])