From bf79914769f0e9e41830adccc09c62636a66f0dd Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Sat, 24 Mar 2018 20:48:44 +0100 Subject: [PATCH] rename function arg --- psutil/_common.py | 6 +++--- psutil/_psaix.py | 4 ++-- psutil/_psbsd.py | 4 ++-- psutil/_pslinux.py | 4 ++-- psutil/_psosx.py | 4 ++-- psutil/_psposix.py | 2 +- psutil/_pssunos.py | 4 ++-- psutil/_pswindows.py | 6 +++--- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/psutil/_common.py b/psutil/_common.py index 870971e41..05dbb4ce6 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -261,14 +261,14 @@ class BatteryTime(enum.IntEnum): # =================================================================== -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 9abc8d17e..662f306c3 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 0553401a5..83f38d55e 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 9f45410f5..78c03d5c5 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 308756a81..193f63e00 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 6bb8444d8..9c3fac27e 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 35b4b092b..e2f33a3ae 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 bb95d2a0d..ab727cba3 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)