Skip to content

Commit

Permalink
Fix sorting issue when attribute is method
Browse files Browse the repository at this point in the history
  • Loading branch information
FrostyX committed Jan 27, 2015
1 parent b1c23af commit 8647146
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions tracer/resources/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,18 @@

from __future__ import absolute_import

from operator import attrgetter
from operator import attrgetter, methodcaller
from psutil import NoSuchProcess
from tracer.resources.system import System


class Collection(list):

def sorted(self, attribute):
return sorted(self, key=attrgetter(attribute))
try:
return sorted(self, key=methodcaller(attribute))
except TypeError:
return sorted(self, key=attrgetter(attribute))


class ApplicationsCollection(Collection):
Expand Down
1 change: 0 additions & 1 deletion tracer/views/resource/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ def render(self):
line = "{0:<10}{1:<20}{2:<20}{3:<10}"
print line.format("PID", "Time running", "User", "Process")
print 100 * "-"
# @FIXME sorting doesn't work correctly
for process in self.args.processes.sorted("create_time"):
print line.format(process.pid, process.str_started_ago, process.username(), process.name())

0 comments on commit 8647146

Please sign in to comment.