From 2449beb7e6c671e20d34bfebcaadaf34180b4b31 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sun, 28 Feb 2016 00:46:52 +0100 Subject: [PATCH] minor refactoring --- psutil/_pslinux.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 74b6cad6c..324ff5cb9 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -1325,17 +1325,14 @@ def open_files(self): # A regular file is always supposed to be have an # absolute path though. if path.startswith('/') and isfile_strict(path): - # Get file position. + # Get file position and flags. file = "%s/%s/fdinfo/%s" % ( self._procfs_path, self.pid, fd) with open_binary(file) as f: - pos = f.readline().split()[1] - flags = f.readline().split()[1] - # flags is an octal number - flags_oct = int(flags, 8) - mode = file_flags_to_mode(flags_oct) - ntuple = popenfile( - path, int(fd), int(pos), mode, flags_oct) + pos = int(f.readline().split()[1]) + flags = int(f.readline().split()[1], 8) + mode = file_flags_to_mode(flags) + ntuple = popenfile(path, int(fd), int(pos), mode, flags) retlist.append(ntuple) if hit_enoent: # raise NSP if the process disappeared on us