summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2017-02-14 20:33:58 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2017-02-14 20:33:58 +0100
commit7ff84c208af10e618e23aacb3691c668eb25a12d (patch)
tree22dd39ac632c25fad7ef8205c9fd3f66a09bcffb
parentdeb5ec3e7042fd7639fe27f50336b041c9b40c69 (diff)
downloadpsutil-7ff84c208af10e618e23aacb3691c668eb25a12d.tar.gz
cosmetic changes
-rw-r--r--psutil/_psbsd.py29
-rw-r--r--psutil/_pslinux.py14
-rw-r--r--psutil/_psosx.py30
-rw-r--r--psutil/_pssunos.py26
-rw-r--r--psutil/_pswindows.py28
-rwxr-xr-xpsutil/tests/test_linux.py7
6 files changed, 62 insertions, 72 deletions
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py
index 72ef71e8..fc5e1dc8 100644
--- a/psutil/_psbsd.py
+++ b/psutil/_psbsd.py
@@ -30,7 +30,7 @@ __extra__all__ = []
# =====================================================================
-# --- constants
+# --- globals
# =====================================================================
@@ -126,26 +126,39 @@ kinfo_proc_map = dict(
name=24,
)
+# these get overwritten on "import psutil" from the __init__.py file
+NoSuchProcess = None
+ZombieProcess = None
+AccessDenied = None
+TimeoutExpired = None
+
# =====================================================================
# --- named tuples
# =====================================================================
-# extend base mem ntuple with BSD-specific memory metrics
+# psutil.virtual_memory()
svmem = namedtuple(
'svmem', ['total', 'available', 'percent', 'used', 'free',
'active', 'inactive', 'buffers', 'cached', 'shared', 'wired'])
+# psutil.cpu_times()
scputimes = namedtuple(
'scputimes', ['user', 'nice', 'system', 'idle', 'irq'])
+# psutil.Process.memory_info()
pmem = namedtuple('pmem', ['rss', 'vms', 'text', 'data', 'stack'])
+# psutil.Process.memory_full_info()
pfullmem = pmem
+# psutil.Process.cpu_times()
pcputimes = namedtuple('pcputimes',
['user', 'system', 'children_user', 'children_system'])
+# psutil.Process.memory_maps(grouped=True)
pmmap_grouped = namedtuple(
'pmmap_grouped', 'path rss, private, ref_count, shadow_count')
+# psutil.Process.memory_maps(grouped=False)
pmmap_ext = namedtuple(
'pmmap_ext', 'addr, perms path rss, private, ref_count, shadow_count')
+# psutil.disk_io_counters()
if FREEBSD:
sdiskio = namedtuple('sdiskio', ['read_count', 'write_count',
'read_bytes', 'write_bytes',
@@ -157,18 +170,6 @@ else:
# =====================================================================
-# --- exceptions
-# =====================================================================
-
-
-# these get overwritten on "import psutil" from the __init__.py file
-NoSuchProcess = None
-ZombieProcess = None
-AccessDenied = None
-TimeoutExpired = None
-
-
-# =====================================================================
# --- memory
# =====================================================================
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index 2c5e97e2..2884e4d1 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -59,11 +59,11 @@ __extra__all__ = [
# =====================================================================
-# --- constants
+# --- globals
# =====================================================================
-POWER_SUPPLY_PATH = "/sys/class/power_supply"
+POWER_SUPPLY_PATH = "/sys/class/power_supply"
HAS_SMAPS = os.path.exists('/proc/%s/smaps' % os.getpid())
HAS_PRLIMIT = hasattr(cext, "linux_prlimit")
_DEFAULT = object()
@@ -137,14 +137,6 @@ TCP_STATUSES = {
"0B": _common.CONN_CLOSING
}
-_DEFAULT = object()
-
-
-# =====================================================================
-# -- exceptions
-# =====================================================================
-
-
# these get overwritten on "import psutil" from the __init__.py file
NoSuchProcess = None
ZombieProcess = None
@@ -529,7 +521,7 @@ def swap_memory():
# =====================================================================
-# --- CPUs
+# --- CPU
# =====================================================================
diff --git a/psutil/_psosx.py b/psutil/_psosx.py
index f22ef2fb..f780d459 100644
--- a/psutil/_psosx.py
+++ b/psutil/_psosx.py
@@ -26,7 +26,7 @@ __extra__all__ = []
# =====================================================================
-# --- constants
+# --- globals
# =====================================================================
@@ -82,28 +82,36 @@ pidtaskinfo_map = dict(
volctxsw=7,
)
-scputimes = namedtuple('scputimes', ['user', 'nice', 'system', 'idle'])
+# these get overwritten on "import psutil" from the __init__.py file
+NoSuchProcess = None
+ZombieProcess = None
+AccessDenied = None
+TimeoutExpired = None
+
+
+# =====================================================================
+# --- named tuples
+# =====================================================================
+
+# psutil.cpu_times()
+scputimes = namedtuple('scputimes', ['user', 'nice', 'system', 'idle'])
+# psutil.virtual_memory()
svmem = namedtuple(
'svmem', ['total', 'available', 'percent', 'used', 'free',
'active', 'inactive', 'wired'])
-
+# psutil.Process.memory_info()
pmem = namedtuple('pmem', ['rss', 'vms', 'pfaults', 'pageins'])
+# psutil.Process.memory_full_info()
pfullmem = namedtuple('pfullmem', pmem._fields + ('uss', ))
-
+# psutil.Process.memory_maps(grouped=True)
pmmap_grouped = namedtuple(
'pmmap_grouped',
'path rss private swapped dirtied ref_count shadow_depth')
-
+# psutil.Process.memory_maps(grouped=False)
pmmap_ext = namedtuple(
'pmmap_ext', 'addr perms ' + ' '.join(pmmap_grouped._fields))
-# these get overwritten on "import psutil" from the __init__.py file
-NoSuchProcess = None
-ZombieProcess = None
-AccessDenied = None
-TimeoutExpired = None
-
# =====================================================================
# --- memory
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py
index 41547a8f..ad72de25 100644
--- a/psutil/_pssunos.py
+++ b/psutil/_pssunos.py
@@ -28,7 +28,7 @@ __extra__all__ = ["CONN_IDLE", "CONN_BOUND", "PROCFS_PATH"]
# =====================================================================
-# --- constants
+# --- globals
# =====================================================================
@@ -66,37 +66,37 @@ TCP_STATUSES = {
cext.TCPS_BOUND: CONN_BOUND, # sunos specific
}
+# these get overwritten on "import psutil" from the __init__.py file
+NoSuchProcess = None
+ZombieProcess = None
+AccessDenied = None
+TimeoutExpired = None
+
# =====================================================================
# --- named tuples
# =====================================================================
+# psutil.cpu_times()
scputimes = namedtuple('scputimes', ['user', 'system', 'idle', 'iowait'])
+# psutil.cpu_times(percpu=True)
pcputimes = namedtuple('pcputimes',
['user', 'system', 'children_user', 'children_system'])
+# psutil.virtual_memory()
svmem = namedtuple('svmem', ['total', 'available', 'percent', 'used', 'free'])
+# psutil.Process.memory_info()
pmem = namedtuple('pmem', ['rss', 'vms'])
pfullmem = pmem
+# psutil.Process.memory_maps(grouped=True)
pmmap_grouped = namedtuple('pmmap_grouped',
['path', 'rss', 'anonymous', 'locked'])
+# psutil.Process.memory_maps(grouped=False)
pmmap_ext = namedtuple(
'pmmap_ext', 'addr perms ' + ' '.join(pmmap_grouped._fields))
# =====================================================================
-# --- exceptions
-# =====================================================================
-
-
-# these get overwritten on "import psutil" from the __init__.py file
-NoSuchProcess = None
-ZombieProcess = None
-AccessDenied = None
-TimeoutExpired = None
-
-
-# =====================================================================
# --- utils
# =====================================================================
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py
index 2b60c55b..0105d6c8 100644
--- a/psutil/_pswindows.py
+++ b/psutil/_pswindows.py
@@ -67,7 +67,7 @@ __extra__all__ = [
# =====================================================================
-# --- constants
+# --- globals
# =====================================================================
@@ -134,28 +134,35 @@ pinfo_map = dict(
mem_private=21,
)
+# these get overwritten on "import psutil" from the __init__.py file
+NoSuchProcess = None
+AccessDenied = None
+TimeoutExpired = None
+
# =====================================================================
# --- named tuples
# =====================================================================
+# psutil.cpu_times()
scputimes = namedtuple('scputimes',
['user', 'system', 'idle', 'interrupt', 'dpc'])
+# psutil.virtual_memory()
svmem = namedtuple('svmem', ['total', 'available', 'percent', 'used', 'free'])
+# psutil.Process.memory_info()
pmem = namedtuple(
'pmem', ['rss', 'vms',
'num_page_faults', 'peak_wset', 'wset', 'peak_paged_pool',
'paged_pool', 'peak_nonpaged_pool', 'nonpaged_pool',
'pagefile', 'peak_pagefile', 'private'])
+# psutil.Process.memory_full_info()
pfullmem = namedtuple('pfullmem', pmem._fields + ('uss', ))
+# psutil.Process.memory_maps(grouped=True)
pmmap_grouped = namedtuple('pmmap_grouped', ['path', 'rss'])
+# psutil.Process.memory_maps(grouped=False)
pmmap_ext = namedtuple(
'pmmap_ext', 'addr perms ' + ' '.join(pmmap_grouped._fields))
-ntpinfo = namedtuple(
- 'ntpinfo', ['num_handles', 'ctx_switches', 'user_time', 'kernel_time',
- 'create_time', 'num_threads', 'io_rcount', 'io_wcount',
- 'io_rbytes', 'io_wbytes'])
# psutil.Process.io_counters()
pio = namedtuple('pio', ['read_count', 'write_count',
'read_bytes', 'write_bytes',
@@ -163,17 +170,6 @@ pio = namedtuple('pio', ['read_count', 'write_count',
# =====================================================================
-# --- exceptions
-# =====================================================================
-
-
-# these get overwritten on "import psutil" from the __init__.py file
-NoSuchProcess = None
-AccessDenied = None
-TimeoutExpired = None
-
-
-# =====================================================================
# --- utils
# =====================================================================
diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py
index 35310b63..8c64afc4 100755
--- a/psutil/tests/test_linux.py
+++ b/psutil/tests/test_linux.py
@@ -1293,13 +1293,6 @@ class TestProcess(unittest.TestCase):
p.cmdline() == ['foo', 'bar', '']
assert m.called
- def test_io_counters_mocked(self):
- with mock.patch('psutil._pslinux.open', create=True) as m:
- self.assertRaises(
- NotImplementedError,
- psutil._pslinux.Process(os.getpid()).io_counters)
- assert m.called
-
def test_readlink_path_deleted_mocked(self):
with mock.patch('psutil._pslinux.os.readlink',
return_value='/home/foo (deleted)'):