summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiampaolo Rodola <g.rodola@gmail.com>2018-03-24 20:48:44 +0100
committerGiampaolo Rodola <g.rodola@gmail.com>2018-03-24 20:48:44 +0100
commitbf79914769f0e9e41830adccc09c62636a66f0dd (patch)
tree5aef7a101615811c3e583ffeae6999261e8ef66c
parentd6445f68faaa332612cebd91bfbfc56f24daed77 (diff)
downloadpsutil-bf79914769f0e9e41830adccc09c62636a66f0dd.tar.gz
rename function arg
-rw-r--r--psutil/_common.py6
-rw-r--r--psutil/_psaix.py4
-rw-r--r--psutil/_psbsd.py4
-rw-r--r--psutil/_pslinux.py4
-rw-r--r--psutil/_psosx.py4
-rw-r--r--psutil/_psposix.py2
-rw-r--r--psutil/_pssunos.py4
-rw-r--r--psutil/_pswindows.py6
8 files changed, 17 insertions, 17 deletions
diff --git a/psutil/_common.py b/psutil/_common.py
index 870971e4..05dbb4ce 100644
--- a/psutil/_common.py
+++ b/psutil/_common.py
@@ -261,14 +261,14 @@ del AF_INET, AF_UNIX, SOCK_STREAM, SOCK_DGRAM
# ===================================================================
-def usage_percent(used, total, _round=None):
+def usage_percent(used, total, round_=None):
"""Calculate percentage usage of 'used' against 'total'."""
try:
ret = (used / total) * 100
except ZeroDivisionError:
ret = 0.0 if isinstance(used, float) or isinstance(total, float) else 0
- if _round is not None:
- return round(ret, _round)
+ if round_ is not None:
+ return round(ret, round_)
else:
return ret
diff --git a/psutil/_psaix.py b/psutil/_psaix.py
index 9abc8d17..662f306c 100644
--- a/psutil/_psaix.py
+++ b/psutil/_psaix.py
@@ -117,7 +117,7 @@ def get_procfs_path():
def virtual_memory():
total, avail, free, pinned, inuse = cext.virtual_mem()
- percent = usage_percent((total - avail), total, _round=1)
+ percent = usage_percent((total - avail), total, round_=1)
return svmem(total, avail, percent, inuse, free)
@@ -125,7 +125,7 @@ def swap_memory():
"""Swap system memory as a (total, used, free, sin, sout) tuple."""
total, free, sin, sout = cext.swap_mem()
used = total - free
- percent = usage_percent(used, total, _round=1)
+ percent = usage_percent(used, total, round_=1)
return _common.sswap(total, used, free, percent, sin, sout)
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py
index 0553401a..83f38d55 100644
--- a/psutil/_psbsd.py
+++ b/psutil/_psbsd.py
@@ -188,7 +188,7 @@ def virtual_memory():
shared = int(line.split()[1]) * 1024
avail = inactive + cached + free
used = active + wired + cached
- percent = usage_percent((total - avail), total, _round=1)
+ percent = usage_percent((total - avail), total, round_=1)
return svmem(total, avail, percent, used, free,
active, inactive, buffers, cached, shared, wired)
@@ -196,7 +196,7 @@ def virtual_memory():
def swap_memory():
"""System swap memory as (total, used, free, sin, sout) namedtuple."""
total, used, free, sin, sout = cext.swap_mem()
- percent = usage_percent(used, total, _round=1)
+ percent = usage_percent(used, total, round_=1)
return _common.sswap(total, used, free, percent, sin, sout)
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index 9f45410f..78c03d5c 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -476,7 +476,7 @@ def virtual_memory():
if avail > total:
avail = free
- percent = usage_percent((total - avail), total, _round=1)
+ percent = usage_percent((total - avail), total, round_=1)
# Warn about missing metrics which are set to 0.
if missing_fields:
@@ -509,7 +509,7 @@ def swap_memory():
free *= unit_multiplier
used = total - free
- percent = usage_percent(used, total, _round=1)
+ percent = usage_percent(used, total, round_=1)
# get pgin/pgouts
try:
f = open_binary("%s/vmstat" % get_procfs_path())
diff --git a/psutil/_psosx.py b/psutil/_psosx.py
index 308756a8..193f63e0 100644
--- a/psutil/_psosx.py
+++ b/psutil/_psosx.py
@@ -122,7 +122,7 @@ def virtual_memory():
total, active, inactive, wired, free = cext.virtual_mem()
avail = inactive + free
used = active + inactive + wired
- percent = usage_percent((total - avail), total, _round=1)
+ percent = usage_percent((total - avail), total, round_=1)
return svmem(total, avail, percent, used, free,
active, inactive, wired)
@@ -130,7 +130,7 @@ def virtual_memory():
def swap_memory():
"""Swap system memory as a (total, used, free, sin, sout) tuple."""
total, used, free, sin, sout = cext.swap_mem()
- percent = usage_percent(used, total, _round=1)
+ percent = usage_percent(used, total, round_=1)
return _common.sswap(total, used, free, percent, sin, sout)
diff --git a/psutil/_psposix.py b/psutil/_psposix.py
index 6bb8444d..9c3fac27 100644
--- a/psutil/_psposix.py
+++ b/psutil/_psposix.py
@@ -156,7 +156,7 @@ def disk_usage(path):
# User usage percent compared to the total amount of space
# the user can use. This number would be higher if compared
# to root's because the user has less space (usually -5%).
- usage_percent_user = usage_percent(used, total_user, _round=1)
+ usage_percent_user = usage_percent(used, total_user, round_=1)
# NB: the percentage is -5% than what shown by df due to
# reserved blocks that we are currently not considering:
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py
index 35b4b092..e2f33a3a 100644
--- a/psutil/_pssunos.py
+++ b/psutil/_pssunos.py
@@ -131,7 +131,7 @@ def virtual_memory():
# note: there's no difference on Solaris
free = avail = os.sysconf('SC_AVPHYS_PAGES') * PAGE_SIZE
used = total - free
- percent = usage_percent(used, total, _round=1)
+ percent = usage_percent(used, total, round_=1)
return svmem(total, avail, percent, used, free)
@@ -163,7 +163,7 @@ def swap_memory():
total += int(int(t) * 512)
free += int(int(f) * 512)
used = total - free
- percent = usage_percent(used, total, _round=1)
+ percent = usage_percent(used, total, round_=1)
return _common.sswap(total, used, free, percent,
sin * PAGE_SIZE, sout * PAGE_SIZE)
diff --git a/psutil/_pswindows.py b/psutil/_pswindows.py
index bb95d2a0..ab727cba 100644
--- a/psutil/_pswindows.py
+++ b/psutil/_pswindows.py
@@ -217,7 +217,7 @@ def virtual_memory():
avail = availphys
free = availphys
used = total - avail
- percent = usage_percent((total - avail), total, _round=1)
+ percent = usage_percent((total - avail), total, round_=1)
return svmem(total, avail, percent, used, free)
@@ -227,7 +227,7 @@ def swap_memory():
total = mem[2]
free = mem[3]
used = total - free
- percent = usage_percent(used, total, _round=1)
+ percent = usage_percent(used, total, round_=1)
return _common.sswap(total, used, free, percent, 0, 0)
@@ -247,7 +247,7 @@ def disk_usage(path):
path = path.decode(ENCODING, errors="strict")
total, free = cext.disk_usage(path)
used = total - free
- percent = usage_percent(used, total, _round=1)
+ percent = usage_percent(used, total, round_=1)
return _common.sdiskusage(total, used, free, percent)