summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2019-06-26 22:41:45 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2019-06-26 22:41:45 +0200
commit46b9a51f3125ddbc79eb088c68a33a52f5c86080 (patch)
treebc45ee327ac1dfac21b28a9167cce087953a7b18
parent0ba4e9d6d40468ff0ea824faed28a68a49bc9f42 (diff)
downloadpsutil-46b9a51f3125ddbc79eb088c68a33a52f5c86080.tar.gz
port AIX
-rw-r--r--psutil/_psaix.py32
1 files changed, 13 insertions, 19 deletions
diff --git a/psutil/_psaix.py b/psutil/_psaix.py
index 3a949d25..79e3be15 100644
--- a/psutil/_psaix.py
+++ b/psutil/_psaix.py
@@ -6,7 +6,6 @@
"""AIX platform implementation."""
-import errno
import functools
import glob
import os
@@ -26,6 +25,9 @@ from ._common import NIC_DUPLEX_FULL
from ._common import NIC_DUPLEX_HALF
from ._common import NIC_DUPLEX_UNKNOWN
from ._common import usage_percent
+from ._compat import FileNotFoundError
+from ._compat import PermissionError
+from ._compat import ProcessLookupError
from ._compat import PY3
@@ -314,22 +316,16 @@ def wrap_exceptions(fun):
def wrapper(self, *args, **kwargs):
try:
return fun(self, *args, **kwargs)
- except EnvironmentError as err:
- # support for private module import
- if (NoSuchProcess is None or AccessDenied is None or
- ZombieProcess is None):
- raise
+ except (FileNotFoundError, ProcessLookupError):
# ENOENT (no such file or directory) gets raised on open().
# ESRCH (no such process) can get raised on read() if
# process is gone in meantime.
- if err.errno in (errno.ENOENT, errno.ESRCH):
- if not pid_exists(self.pid):
- raise NoSuchProcess(self.pid, self._name)
- else:
- raise ZombieProcess(self.pid, self._name, self._ppid)
- if err.errno in (errno.EPERM, errno.EACCES):
- raise AccessDenied(self.pid, self._name)
- raise
+ if not pid_exists(self.pid):
+ raise NoSuchProcess(self.pid, self._name)
+ else:
+ raise ZombieProcess(self.pid, self._name, self._ppid)
+ except PermissionError:
+ raise AccessDenied(self.pid, self._name)
return wrapper
@@ -488,11 +484,9 @@ class Process(object):
try:
result = os.readlink("%s/%s/cwd" % (procfs_path, self.pid))
return result.rstrip('/')
- except OSError as err:
- if err.errno == errno.ENOENT:
- os.stat("%s/%s" % (procfs_path, self.pid)) # raise NSP or AD
- return None
- raise
+ except FileNotFoundError:
+ os.stat("%s/%s" % (procfs_path, self.pid)) # raise NSP or AD
+ return None
@wrap_exceptions
def memory_info(self):