Skip to content

Commit

Permalink
There is children instead of get_children in psutil2
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Feb 23, 2015
1 parent 269865a commit 4ce8134
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/test_processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TestProcesses(unittest.TestCase):

def test_children(self):
process = Processes.all()[0]
children = process.get_children()
children = process.children()
self.assertIsInstance(children, ProcessesCollection)

for child in children:
Expand Down
8 changes: 6 additions & 2 deletions tracer/resources/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ def username(self):
def create_time(self):
return self._attr("create_time")

def children(self, recursive=False):
try: return self._process.children()
except AttributeError: return self._process.get_children()

def _attr(self, name):
attr = getattr(self._process, name)
try: return attr()
Expand Down Expand Up @@ -130,10 +134,10 @@ def username(self):
except KeyError:
return None

def get_children(self, recursive=False):
def children(self, recursive=False):
"""The collection of process's children. Each of them casted from ``psutil.Process``
to tracer ``Process``."""
children = super(Process, self).get_children(recursive)
children = super(Process, self).children(recursive)
for child in children:
child.__class__ = Process
return ProcessesCollection(children)
Expand Down
2 changes: 1 addition & 1 deletion tracer/resources/tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ def _affecting_children(self, process, packages):
return {}

processes = AffectedProcessesCollection()
for child in process.get_children():
for child in process.children():
processes.update(self._affecting_processes(child, packages))
return processes

0 comments on commit 4ce8134

Please sign in to comment.