Skip to content

Commit

Permalink
Add compatibility layer for psutil.pids(); Fix 1251687
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Aug 10, 2015
1 parent 0d57ee6 commit 2ce501a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tracer/resources/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,18 @@

class Processes(object):

# psutil 3.x to 1.x backward compatibility
@staticmethod
def pids():
try:
return psutil.pids()
except AttributeError:
return psutil.get_pid_list()

@staticmethod
def all():
processes = ProcessesCollection()
for pid in psutil.pids():
for pid in Processes.pids():
try:
processes.append(Process(pid))
except psutil.NoSuchProcess: pass
Expand Down Expand Up @@ -88,6 +96,11 @@ def _attr(self, name):
def __getattr__(self, item):
return getattr(self._process, item)

# psutil 3.x to 1.x backward compatibility
def memory_maps(self, grouped=True):
try: return self._process.memory_maps(grouped=grouped)
except AttributeError: return self._process.get_memory_maps()


class Process(ProcessWrapper):
"""
Expand Down

0 comments on commit 2ce501a

Please sign in to comment.