summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2021-10-14 22:14:53 +0200
committerGiampaolo Rodola <g.rodola@gmail.com>2021-10-14 22:14:53 +0200
commite91bae62e6e6ee9c3ad27c1fe3013f929309e1b0 (patch)
tree9e897a5be67cfcf8356c8e2d616b0dc47ca794ad
parent4d03c917561297de1e6017059c60eb879cf8353c (diff)
downloadpsutil-e91bae62e6e6ee9c3ad27c1fe3013f929309e1b0.tar.gz
add debug() prints in a couple of places
Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
-rw-r--r--psutil/_common.py2
-rw-r--r--psutil/_pslinux.py8
-rw-r--r--psutil/_pssunos.py2
-rw-r--r--psutil/_pswindows.py2
4 files changed, 10 insertions, 4 deletions
diff --git a/psutil/_common.py b/psutil/_common.py
index 879e8477..a2b8bab6 100644
--- a/psutil/_common.py
+++ b/psutil/_common.py
@@ -836,6 +836,8 @@ if bool(os.getenv('PSUTIL_DEBUG', 0)):
"""If PSUTIL_DEBUG env var is set, print a debug message to stderr."""
fname, lineno, func_name, lines, index = inspect.getframeinfo(
inspect.currentframe().f_back)
+ if isinstance(msg, Exception):
+ msg = "ignoring %s" % msg
print("psutil-debug [%s:%s]> %s" % (fname, lineno, msg), # NOQA
file=sys.stderr)
else:
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index f6a83301..57925b87 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -834,6 +834,7 @@ class Connections:
continue
if err.errno == errno.ENAMETOOLONG:
# file name too long
+ debug(err)
continue
raise
else:
@@ -1081,6 +1082,8 @@ def net_if_stats():
# https://github.com/giampaolo/psutil/issues/1279
if err.errno != errno.ENODEV:
raise
+ else:
+ debug(err)
else:
ret[name] = _common.snicstats(isup, duplex_map[duplex], speed, mtu)
return ret
@@ -1387,7 +1390,7 @@ def sensors_temperatures():
path = os.path.join(base, 'type')
unit_name = cat(path, binary=False)
except (IOError, OSError, ValueError) as err:
- debug("ignoring %r for file %r" % (err, path))
+ debug(err)
continue
trip_paths = glob.glob(base + '/trip_point*')
@@ -1443,7 +1446,7 @@ def sensors_fans():
try:
current = int(cat(base + '_input'))
except (IOError, OSError) as err:
- warnings.warn("ignoring %r" % err, RuntimeWarning)
+ debug(err)
continue
unit_name = cat(os.path.join(os.path.dirname(base), 'name'),
binary=False)
@@ -2182,6 +2185,7 @@ class Process(object):
continue
if err.errno == errno.ENAMETOOLONG:
# file name too long
+ debug(err)
continue
raise
else:
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py
index 84d78814..355a7623 100644
--- a/psutil/_pssunos.py
+++ b/psutil/_pssunos.py
@@ -231,7 +231,7 @@ def disk_partitions(all=False):
continue
except OSError as err:
# https://github.com/giampaolo/psutil/issues/1674
- debug("skipping %r: %r" % (mountpoint, err))
+ debug("skipping %r: %s" % (mountpoint, err))
continue
maxfile = maxpath = None # set later
ntuple = _common.sdiskpart(device, mountpoint, fstype, opts,
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py
index 6b1a34de..348b72e1 100644
--- a/psutil/_pswindows.py
+++ b/psutil/_pswindows.py
@@ -767,7 +767,7 @@ class Process(object):
# 24 = ERROR_TOO_MANY_OPEN_FILES. Not sure why this happens
# (perhaps PyPy's JIT delaying garbage collection of files?).
if err.errno == 24:
- debug("%r forced into AccessDenied" % err)
+ debug("%r translated into AccessDenied" % err)
raise AccessDenied(self.pid, self._name)
raise
else: