Skip to content

Commit

Permalink
Fix function naming and counter string
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Oct 21, 2022
1 parent e3dc04e commit 366b4e1
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion psutil/_psutil_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ PsutilMethods[] = {
{"disk_usage", psutil_disk_usage, METH_VARARGS},
{"getloadavg", (PyCFunction)psutil_get_loadavg, METH_VARARGS},
{"getpagesize", psutil_getpagesize, METH_VARARGS},
{"getpercentswap", (PyCFunction)psutil_get_loadavg, METH_VARARGS},
{"getpercentswap", (PyCFunction)psutil_get_percentswap, METH_VARARGS},
{"init_loadavg_counter", (PyCFunction)psutil_init_loadavg_counter, METH_VARARGS},
{"net_connections", psutil_net_connections, METH_VARARGS},
{"net_if_addrs", psutil_net_if_addrs, METH_VARARGS},
Expand Down
2 changes: 1 addition & 1 deletion psutil/_pswindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def swap_memory():
# while the corresponding free physical value is not decremented until
# pages are accessed, so we ignore free system memory and calculate
# page file usage based on performance counter
percentswap = cext.percentswap()
percentswap = cext.getpercentswap()
used = int(percentswap * total)
free = total - used
percent = usage_percent(used, total, round_=1)
Expand Down
2 changes: 1 addition & 1 deletion psutil/arch/windows/wmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ psutil_get_loadavg(PyObject *self, PyObject *args) {
*/
PyObject *
psutil_get_percentswap(PyObject *self, PyObject *args) {
WCHAR *szCounterPath = L"\\PagingFile(_Total)\\% Usage";
WCHAR *szCounterPath = L"\\Paging File(_Total)\\% Usage";
PDH_STATUS s;
HQUERY hQuery;
HCOUNTER hCounter;
Expand Down
6 changes: 0 additions & 6 deletions psutil/tests/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@ def test_percent_swapmem(self):
percentSwap = int(w.PercentUsage) * 100 / int(w.PercentUsage_Base)
# exact percent may change but should be reasonable
# assert within +/- 5% and between 0 and 100
# check the pdh class
self.assertGreaterEqual(psutil.percentswap(), 0)
self.assertAlmostEqual(psutil.percentswap(), percentSwap,
delta=5)
self.assertLessEqual(psutil.percentswap(), 100)
# check the end result
self.assertGreaterEqual(psutil.swap_memory().percent, 0)
self.assertAlmostEqual(psutil.swap_memory().percent, percentSwap,
delta=5)
Expand Down

0 comments on commit 366b4e1

Please sign in to comment.