def _get_owner(self): uid = self.owner if uid is None: return try: return getpwuid_cached(uid).pw_name except KeyError as e: return str(uid)
def __init__(self, pid): bincmd = file(os.path.join('/proc', str(pid), 'cmdline'), 'rb').read() self.arguments = bincmd.split('\x00') owner_uid = -1 for line in file(os.path.join('/proc', str(pid), 'status')): match = _uid_re.search(line) if match: owner_uid = int(match.group(1)) super(LinuxProcess, self).__init__(pid, string.join(self.arguments, ' '), getpwuid_cached(owner_uid).pw_name)