diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2022-09-19 13:02:03 +0200 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2022-09-19 13:02:03 +0200 |
commit | 3cd1a6d14c96bd83434cb6240cc7a35f995af0ab (patch) | |
tree | 30731fd5cf99b96c545303c604ffd1f9a577fbe7 | |
parent | 5d46b358d31ff7f0a67b104ad4cffffa032b3b35 (diff) | |
parent | 642438375e685403b4cd60b0c0e25b80dd5a813d (diff) | |
download | psutil-3cd1a6d14c96bd83434cb6240cc7a35f995af0ab.tar.gz |
Merge branch 'kianmeng-fix-typos'
-rw-r--r-- | CONTRIBUTING.md | 2 | ||||
-rw-r--r-- | HISTORY.rst | 16 | ||||
-rw-r--r-- | INSTALL.rst | 2 | ||||
-rw-r--r-- | appveyor.yml | 2 | ||||
-rw-r--r-- | docs/DEVGUIDE.rst | 2 | ||||
-rw-r--r-- | docs/index.rst | 4 | ||||
-rw-r--r-- | psutil/__init__.py | 6 | ||||
-rw-r--r-- | psutil/_pslinux.py | 6 | ||||
-rw-r--r-- | psutil/_psutil_common.c | 2 | ||||
-rw-r--r-- | psutil/_psutil_sunos.c | 6 | ||||
-rw-r--r-- | psutil/arch/freebsd/sensors.c | 2 | ||||
-rw-r--r-- | psutil/arch/solaris/environ.c | 8 | ||||
-rw-r--r-- | psutil/arch/windows/cpu.c | 6 | ||||
-rw-r--r-- | psutil/tests/__init__.py | 4 | ||||
-rwxr-xr-x | psutil/tests/test_bsd.py | 2 | ||||
-rwxr-xr-x | psutil/tests/test_linux.py | 2 | ||||
-rwxr-xr-x | psutil/tests/test_process.py | 4 | ||||
-rwxr-xr-x | psutil/tests/test_windows.py | 2 | ||||
-rwxr-xr-x | scripts/internal/download_wheels_appveyor.py | 2 | ||||
-rwxr-xr-x | scripts/internal/fix_flake8.py | 185 | ||||
-rwxr-xr-x | scripts/iotop.py | 2 | ||||
-rwxr-xr-x | setup.py | 2 |
22 files changed, 227 insertions, 42 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 481793fc..250398f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ Pull Requests * The PR system is for fixing bugs or make enhancements related to the **program code**. -* If you whish to implement a new feature or add support for a new platform it's +* If you wish to implement a new feature or add support for a new platform it's better to **discuss it first**, either on the issue tracker, the forum or via private email. * In order to get acquainted with the code base and tooling, take a look at the diff --git a/HISTORY.rst b/HISTORY.rst index a0a3bb25..da1acd54 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -346,7 +346,7 @@ XXXX-XX-XX - 1276_, [AIX]: can't get whole `Process.cmdline()`_. (patch by Arnon Yaari) - 1501_, [Windows]: `Process.cmdline()`_ and `Process.exe()`_ raise unhandled "WinError 1168 element not found" exceptions for "Registry" and - "Memory Compression" psuedo processes on Windows 10. + "Memory Compression" pseudo processes on Windows 10. - 1526_, [NetBSD], **[critical]**: `Process.cmdline()`_ could raise ``MemoryError``. (patch by Kamil Rytarowski) @@ -385,9 +385,9 @@ XXXX-XX-XX - 1471_, [SunOS]: `Process.name()`_ and `Process.cmdline()`_ can return ``SystemError``. (patch by Daniel Beer) - 1472_, [Linux]: `cpu_freq()`_ does not return all CPUs on Rasbperry-pi 3. -- 1474_: fix formatting of ``psutil.tests()`` which mimicks ``ps aux`` output. +- 1474_: fix formatting of ``psutil.tests()`` which mimics ``ps aux`` output. - 1475_, [Windows], **[critical]**: ``OSError.winerror`` attribute wasn't - properly checked resuling in ``WindowsError(ERROR_ACCESS_DENIED)`` being + properly checked resulting in ``WindowsError(ERROR_ACCESS_DENIED)`` being raised instead of `AccessDenied`_. - 1477_, [Windows]: wrong or absent error handling for private ``NTSTATUS`` Windows APIs. Different process methods were affected by this. @@ -1351,7 +1351,7 @@ XXXX-XX-XX **Bug fixes** - 340_, [Windows], **[critical]**: `Process.open_files()`_ no longer hangs. - Instead it uses a thred which times out and skips the file handle in case it's + Instead it uses a thread which times out and skips the file handle in case it's taking too long to be retrieved. (patch by Jeff Tang) - 627_, [Windows]: `Process.name()`_ no longer raises `AccessDenied`_ for pids owned by another user. @@ -1360,7 +1360,7 @@ XXXX-XX-XX affect ``os.getpid()`` 's process group and not PID 0. - 639_, [Linux]: `Process.cmdline()`_ can be truncated. - 640_, [Linux]: ``*connections`` functions may swallow errors and return an - incomplete list of connnections. + incomplete list of connections. - 642_: ``repr()`` of exceptions is incorrect. - 653_, [Windows]: add ``inet_ntop()`` function for Windows XP to support IPv6. - 641_, [Windows]: replace deprecated string functions with safe equivalents. @@ -1431,7 +1431,7 @@ XXXX-XX-XX **Bug fixes** -- 572_, [Linux]: fix "ValueError: ambiguos inode with multiple PIDs references" +- 572_, [Linux]: fix "ValueError: ambiguous inode with multiple PIDs references" for `Process.connections()`_. (patch by Bruno Binet) 2.2.0 @@ -1875,7 +1875,7 @@ In most cases accessing the old names will work but it will cause a the PPID to 1 in case of a zombie process. - 323_, [macOS]: `disk_io_counters()`_ ``read_time`` and ``write_time`` parameters were reporting microseconds not milliseconds. (patch by Gregory Szorc) -- 331_: `Process.cmdline()`_ is no longer cached after first acces as it may +- 331_: `Process.cmdline()`_ is no longer cached after first access as it may change. - 333_, [macOS]: leak of Mach ports (patch by rsesek@google.com) - 337_, [Linux], **[critical]**: `Process`_ methods not working because of a @@ -2232,7 +2232,7 @@ In most cases accessing the old names will work but it will cause a - 113_: exception messages now include `Process.name()`_ and `Process.pid`_. - 114_, [Windows]: `Process.username()`_ has been rewritten in pure C and no longer uses WMI resulting in a big speedup. Also, pywin32 is no longer - required as a third-party dependancy. (patch by wj32) + required as a third-party dependency. (patch by wj32) - 117_, [Windows]: added support for Windows 2000. - 123_: `cpu_percent()`_ and `Process.cpu_percent()`_ accept a new ``interval`` parameter. diff --git a/INSTALL.rst b/INSTALL.rst index c7efea5e..46aee6cd 100644 --- a/INSTALL.rst +++ b/INSTALL.rst @@ -9,7 +9,7 @@ install a C compiler. All you have to do is:: pip install psutil -If wheels are not available for your platform or architecture, or you whish to +If wheels are not available for your platform or architecture, or you wish to build & install psutil from sources, keep reading. Linux (build) diff --git a/appveyor.yml b/appveyor.yml index 3c26939e..4bbd51ae 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ matrix: environment: global: # SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the - # /E:ON and /V:ON options are not enabled in the batch script intepreter + # /E:ON and /V:ON options are not enabled in the batch script interpreter # See: http://stackoverflow.com/a/13751649/163740 WITH_COMPILER: "cmd /E:ON /V:ON /C .\\.ci\\appveyor\\run_with_compiler.cmd" PYTHONWARNINGS: always diff --git a/docs/DEVGUIDE.rst b/docs/DEVGUIDE.rst index d4e6778f..384f8b25 100644 --- a/docs/DEVGUIDE.rst +++ b/docs/DEVGUIDE.rst @@ -32,7 +32,7 @@ Once you have a compiler installed: make uninstall make help -- if you're working on a new feature and you whish to compile & test it "on the +- if you're working on a new feature and you wish to compile & test it "on the fly" from a test script, this is a quick & dirty way to do it: .. code-block:: bash diff --git a/docs/index.rst b/docs/index.rst index c30f7d6a..aa0fd932 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1604,7 +1604,7 @@ Process class Return a named tuple with variable fields depending on the platform representing memory information about the process. - The "portable" fields available on all plaforms are `rss` and `vms`. + The "portable" fields available on all platforms are `rss` and `vms`. All numbers are expressed in bytes. +---------+---------+-------+---------+-----+------------------------------+ @@ -2550,7 +2550,7 @@ FAQs ==== * Q: Why do I get :class:`AccessDenied` for certain processes? -* A: This may happen when you query processess owned by another user, +* A: This may happen when you query processes owned by another user, especially on macOS (see `issue #883`_) and Windows. Unfortunately there's not much you can do about this except running the Python process with higher privileges. diff --git a/psutil/__init__.py b/psutil/__init__.py index 475059f2..ca2d9273 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -373,7 +373,7 @@ class Process(object): raise NoSuchProcess(pid, msg='process PID not found') else: self._gone = True - # This pair is supposed to indentify a Process instance + # This pair is supposed to identify a Process instance # univocally over time (the PID alone is not enough as # it might refer to a process whose PID has been reused). # This will be used later in __eq__() and is_running(). @@ -1051,7 +1051,7 @@ class Process(object): """Return a namedtuple with variable fields depending on the platform, representing memory information about the process. - The "portable" fields available on all plaforms are `rss` and `vms`. + The "portable" fields available on all platforms are `rss` and `vms`. All numbers are expressed in bytes. """ @@ -1205,7 +1205,7 @@ class Process(object): def suspend(self): """Suspend process execution with SIGSTOP pre-emptively checking whether PID has been reused. - On Windows this has the effect ot suspending all process threads. + On Windows this has the effect of suspending all process threads. """ if POSIX: self._send_signal(signal.SIGSTOP) diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index 57349889..206241f6 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -243,7 +243,7 @@ def is_storage_device(name): "nvme0n1p1"). If name is a virtual device (e.g. "loop1", "ram") return True. """ - # Readapted from iostat source code, see: + # Re-adapted from iostat source code, see: # https://github.com/sysstat/sysstat/blob/ # 97912938cd476645b267280069e83b1c8dc0e1c7/common.c#L208 # Some devices may have a slash in their name (e.g. cciss/c0d0...). @@ -916,7 +916,7 @@ class Connections: # # out if there are multiple references to the # # same inode. We won't do this for UNIX sockets. # if len(inodes[inode]) > 1 and family != socket.AF_UNIX: - # raise ValueError("ambiguos inode with multiple " + # raise ValueError("ambiguous inode with multiple " # "PIDs references") pid, fd = inodes[inode][0] else: @@ -1687,7 +1687,7 @@ class Process(object): data = bcat("%s/%s/stat" % (self._procfs_path, self.pid)) # Process name is between parentheses. It can contain spaces and # other parentheses. This is taken into account by looking for - # the first occurrence of "(" and the last occurence of ")". + # the first occurrence of "(" and the last occurrence of ")". rpar = data.rfind(b')') name = data[data.find(b'(') + 1:rpar] fields = data[rpar + 2:].split() diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c index 9679da67..096e2f37 100644 --- a/psutil/_psutil_common.c +++ b/psutil/_psutil_common.c @@ -319,7 +319,7 @@ psutil_loadlibs() { // minimum requirement: Win 7 GetActiveProcessorCount = psutil_GetProcAddress( "kernel32", "GetActiveProcessorCount"); - // minumum requirement: Win 7 + // minimum requirement: Win 7 GetLogicalProcessorInformationEx = psutil_GetProcAddressFromLib( "kernel32", "GetLogicalProcessorInformationEx"); // minimum requirements: Windows Server Core diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c index 42a1ffe8..84bf1c40 100644 --- a/psutil/_psutil_sunos.c +++ b/psutil/_psutil_sunos.c @@ -124,7 +124,7 @@ psutil_proc_basic_info(PyObject *self, PyObject *args) { } /* - * Join array of C strings to C string with delemiter dm. + * Join array of C strings to C string with delimiter dm. * Omit empty records. */ static int @@ -1255,7 +1255,7 @@ psutil_net_connections(PyObject *self, PyObject *args) { lport = tp.tcpConnLocalPort; rport = tp.tcpConnRemPort; - // contruct python tuple/list + // construct python tuple/list py_laddr = Py_BuildValue("(si)", lip, lport); if (!py_laddr) goto error; @@ -1300,7 +1300,7 @@ psutil_net_connections(PyObject *self, PyObject *args) { lport = tp6.tcp6ConnLocalPort; rport = tp6.tcp6ConnRemPort; - // contruct python tuple/list + // construct python tuple/list py_laddr = Py_BuildValue("(si)", lip, lport); if (!py_laddr) goto error; diff --git a/psutil/arch/freebsd/sensors.c b/psutil/arch/freebsd/sensors.c index ce7b2d92..0042adbe 100644 --- a/psutil/arch/freebsd/sensors.c +++ b/psutil/arch/freebsd/sensors.c @@ -64,7 +64,7 @@ psutil_sensors_cpu_temperature(PyObject *self, PyObject *args) { goto error; current = DECIKELVIN_2_CELCIUS(current); - // Return -273 in case of faliure. + // Return -273 in case of failure. sprintf(sensor, "dev.cpu.%d.coretemp.tjmax", core); if (sysctlbyname(sensor, &tjmax, &size, NULL, 0)) tjmax = 0; diff --git a/psutil/arch/solaris/environ.c b/psutil/arch/solaris/environ.c index 482fe1fc..58afd63a 100644 --- a/psutil/arch/solaris/environ.c +++ b/psutil/arch/solaris/environ.c @@ -227,7 +227,7 @@ is_ptr_dereference_possible(psinfo_t info) { /* * Return pointer size according to psinfo_t structure - * @param info a ponter to process info (psinfo_t) structure of the + * @param info a pointer to process info (psinfo_t) structure of the * interesting process. * @return pointer size (4 or 8). */ @@ -284,9 +284,9 @@ search_pointers_vector_size_offt(int fd, off_t offt, size_t ptr_size) { /* - * Derefence and read array of strings by psinfo_t.pr_argv pointer from + * Dereference and read array of strings by psinfo_t.pr_argv pointer from * remote process. - * @param info a ponter to process info (psinfo_t) structure of the + * @param info a pointer to process info (psinfo_t) structure of the * interesting process * @param procfs_path a cstring with path to mounted procfs filesystem. * @param count a pointer to variable where to store amount of elements in @@ -333,7 +333,7 @@ psutil_read_raw_args(psinfo_t info, const char *procfs_path, size_t *count) { /* * Dereference and read array of strings by psinfo_t.pr_envp pointer * from remote process. - * @param info a ponter to process info (psinfo_t) structure of the + * @param info a pointer to process info (psinfo_t) structure of the * interesting process. * @param procfs_path a cstring with path to mounted procfs filesystem. * @param count a pointer to variable where to store amount of elements in diff --git a/psutil/arch/windows/cpu.c b/psutil/arch/windows/cpu.c index 20c01a0d..9d89e5bb 100644 --- a/psutil/arch/windows/cpu.c +++ b/psutil/arch/windows/cpu.c @@ -100,7 +100,7 @@ psutil_per_cpu_times(PyObject *self, PyObject *args) { goto error; } - // gets cpu time informations + // gets cpu time information status = NtQuerySystemInformation( SystemProcessorPerformanceInformation, sppi, @@ -172,7 +172,7 @@ psutil_cpu_count_logical(PyObject *self, PyObject *args) { if (ncpus != 0) return Py_BuildValue("I", ncpus); else - Py_RETURN_NONE; // mimick os.cpu_count() + Py_RETURN_NONE; // mimic os.cpu_count() } @@ -248,7 +248,7 @@ psutil_cpu_count_cores(PyObject *self, PyObject *args) { } else { psutil_debug("GetLogicalProcessorInformationEx() count was 0"); - Py_RETURN_NONE; // mimick os.cpu_count() + Py_RETURN_NONE; // mimic os.cpu_count() } return_none: diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 6b40fdc6..6ddafc97 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -308,7 +308,7 @@ def spawn_testproc(cmd=None, **kwds): return it as a subprocess.Popen instance. If "cmd" is specified that is used instead of python. By default stdin and stdout are redirected to /dev/null. - It also attemps to make sure the process is in a reasonably + It also attempts to make sure the process is in a reasonably initialized state. The process is registered for cleanup on reap_children(). """ @@ -563,7 +563,7 @@ def reap_children(recursive=False): """Terminate and wait() any subprocess started by this test suite and any children currently running, ensuring that no processes stick around to hog resources. - If resursive is True it also tries to terminate and wait() + If recursive is True it also tries to terminate and wait() all grandchildren started by this process. """ # Get the children here before terminating them, as in case of diff --git a/psutil/tests/test_bsd.py b/psutil/tests/test_bsd.py index a236810d..e541547d 100755 --- a/psutil/tests/test_bsd.py +++ b/psutil/tests/test_bsd.py @@ -115,7 +115,7 @@ class BSDTestCase(PsutilTestCase): dev, total, used, free = df(part.mountpoint) self.assertEqual(part.device, dev) self.assertEqual(usage.total, total) - # 10 MB tollerance + # 10 MB tolerance if abs(usage.free - free) > 10 * 1024 * 1024: raise self.fail("psutil=%s, df=%s" % (usage.free, free)) if abs(usage.used - used) > 10 * 1024 * 1024: diff --git a/psutil/tests/test_linux.py b/psutil/tests/test_linux.py index c53dfd8a..3e1afc4f 100755 --- a/psutil/tests/test_linux.py +++ b/psutil/tests/test_linux.py @@ -704,7 +704,7 @@ class TestSystemCPUCountLogical(PsutilTestCase): assert m.called # Let's have open() return empty data and make sure None is - # returned ('cause we mimick os.cpu_count()). + # returned ('cause we mimic os.cpu_count()). with mock.patch('psutil._common.open', create=True) as m: self.assertIsNone(psutil._pslinux.cpu_count_logical()) self.assertEqual(m.call_count, 2) diff --git a/psutil/tests/test_process.py b/psutil/tests/test_process.py index eb17e239..a79daabd 100755 --- a/psutil/tests/test_process.py +++ b/psutil/tests/test_process.py @@ -700,7 +700,7 @@ class TestProcess(PsutilTestCase): self.assertEqual(exe.replace(ver, ''), PYTHON_EXE.replace(ver, '')) except AssertionError: - # Tipically MACOS. Really not sure what to do here. + # Typically MACOS. Really not sure what to do here. pass out = sh([exe, "-c", "import os; print('hey')"]) @@ -1534,7 +1534,7 @@ class TestPopen(PsutilTestCase): def test_misc(self): # XXX this test causes a ResourceWarning on Python 3 because - # psutil.__subproc instance doesn't get propertly freed. + # psutil.__subproc instance doesn't get properly freed. # Not sure what to do though. cmd = [PYTHON_EXE, "-c", "import time; time.sleep(60);"] with psutil.Popen(cmd, stdout=subprocess.PIPE, diff --git a/psutil/tests/test_windows.py b/psutil/tests/test_windows.py index b89c67a9..3bf45807 100755 --- a/psutil/tests/test_windows.py +++ b/psutil/tests/test_windows.py @@ -167,7 +167,7 @@ class TestSystemAPIs(WindowsTestCase): self.assertEqual(usage.total, int(wmi_part.Size)) wmi_free = int(wmi_part.FreeSpace) self.assertEqual(usage.free, wmi_free) - # 10 MB tollerance + # 10 MB tolerance if abs(usage.free - wmi_free) > 10 * 1024 * 1024: raise self.fail("psutil=%s, wmi=%s" % ( usage.free, wmi_free)) diff --git a/scripts/internal/download_wheels_appveyor.py b/scripts/internal/download_wheels_appveyor.py index e4d6ffc0..786e23d8 100755 --- a/scripts/internal/download_wheels_appveyor.py +++ b/scripts/internal/download_wheels_appveyor.py @@ -7,7 +7,7 @@ """ Script which downloads wheel files hosted on AppVeyor: https://ci.appveyor.com/project/giampaolo/psutil -Readapted from the original recipe of Ibarra Corretge' +Re-adapted from the original recipe of Ibarra Corretge' <saghul@gmail.com>: http://code.saghul.net/index.php/2015/09/09/ """ diff --git a/scripts/internal/fix_flake8.py b/scripts/internal/fix_flake8.py new file mode 100755 index 00000000..44da4a32 --- /dev/null +++ b/scripts/internal/fix_flake8.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python3 + +# Copyright (c) 2009, Giampaolo Rodola'. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +""" +Fix some flake8 errors by rewriting files for which flake8 emitted +an error/warning. Usage (from the root dir): + + $ python3 -m flake8 --exit-zero | python3 scripts/fix_flake8.py +""" + +import shutil +import sys +import tempfile +from collections import defaultdict +from collections import namedtuple +from pprint import pprint as pp # NOQA + + +ntentry = namedtuple('ntentry', 'msg, issue, lineno, pos, descr') + + +# ===================================================================== +# utils +# ===================================================================== + + +def enter_pdb(): + from pdb import set_trace as st # trick GIT commit hook + sys.stdin = open('/dev/tty') + st() + + +def read_lines(fname): + with open(fname, 'rt') as f: + return f.readlines() + + +def read_line(fname, lineno): + with open(fname, 'rt') as f: + for i, line in enumerate(f, 1): + if i == lineno: + return line + raise ValueError("lineno too big") + + +def write_file(fname, newlines): + with tempfile.NamedTemporaryFile('wt', delete=False) as f: + for line in newlines: + f.write(line) + shutil.move(f.name, fname) + + +# ===================================================================== +# handlers +# ===================================================================== + + +def handle_f401(fname, lineno): + """ This is 'module imported but not used' + Able to handle this case: + import os + + ...but not this: + from os import listdir + """ + line = read_line(fname, lineno).strip() + if line.startswith('import '): + return True + else: + mods = line.partition(' import ')[2] # everything after import + return ',' not in mods + + +# ===================================================================== +# converters +# ===================================================================== + + +def remove_lines(fname, entries): + """Check if we should remove lines, then do it. + Return the number of lines removed. + """ + to_remove = [] + for entry in entries: + msg, issue, lineno, pos, descr = entry + # 'module imported but not used' + if issue == 'F401' and handle_f401(fname, lineno): + to_remove.append(lineno) + # 'blank line(s) at end of file' + elif issue == 'W391': + lines = read_lines(fname) + i = len(lines) - 1 + while lines[i] == '\n': + to_remove.append(i + 1) + i -= 1 + # 'too many blank lines' + elif issue == 'E303': + howmany = descr.replace('(', '').replace(')', '') + howmany = int(howmany[-1]) + for x in range(lineno - howmany, lineno): + to_remove.append(x) + + if to_remove: + newlines = [] + for i, line in enumerate(read_lines(fname), 1): + if i not in to_remove: + newlines.append(line) + print("removing line(s) from %s" % fname) + write_file(fname, newlines) + + return len(to_remove) + + +def add_lines(fname, entries): + """Check if we should remove lines, then do it. + Return the number of lines removed. + """ + EXPECTED_BLANK_LINES = ( + 'E302', # 'expected 2 blank limes, found 1' + 'E305') # ìexpected 2 blank lines after class or fun definition' + to_add = {} + for entry in entries: + msg, issue, lineno, pos, descr = entry + if issue in EXPECTED_BLANK_LINES: + howmany = 2 if descr.endswith('0') else 1 + to_add[lineno] = howmany + + if to_add: + newlines = [] + for i, line in enumerate(read_lines(fname), 1): + if i in to_add: + newlines.append('\n' * to_add[i]) + newlines.append(line) + print("adding line(s) to %s" % fname) + write_file(fname, newlines) + + return len(to_add) + + +# ===================================================================== +# main +# ===================================================================== + + +def build_table(): + table = defaultdict(list) + for line in sys.stdin: + line = line.strip() + if not line: + break + fields = line.split(':') + fname, lineno, pos = fields[:3] + issue = fields[3].split()[0] + descr = fields[3].strip().partition(' ')[2] + lineno, pos = int(lineno), int(pos) + table[fname].append(ntentry(line, issue, lineno, pos, descr)) + return table + + +def main(): + table = build_table() + + # remove lines (unused imports) + removed = 0 + for fname, entries in table.items(): + removed += remove_lines(fname, entries) + if removed: + print("%s lines were removed from some file(s); please re-run" % + removed) + return + + # add lines (missing \n between functions/classes) + added = 0 + for fname, entries in table.items(): + added += add_lines(fname, entries) + if added: + print("%s lines were added from some file(s); please re-run" % + added) + return + + +main() diff --git a/scripts/iotop.py b/scripts/iotop.py index 91bc3b18..f4d62d46 100755 --- a/scripts/iotop.py +++ b/scripts/iotop.py @@ -65,7 +65,7 @@ def printl(line, highlight=False): def poll(interval): - """Calculate IO usage by comparing IO statics before and + """Calculate IO usage by comparing IO statistics before and after the interval. Return a tuple including all currently running processes sorted by IO activity and total disks I/O activity. @@ -327,7 +327,7 @@ if POSIX: # Detect Solaris 5.10, update >= 4, see: # https://github.com/giampaolo/psutil/pull/1638 if get_sunos_update() >= 4: - # MIB compliancy starts with SunOS 5.10 Update 4: + # MIB compliance starts with SunOS 5.10 Update 4: posix_extension.define_macros.append(('NEW_MIB_COMPLIANT', 1)) posix_extension.sources.append('psutil/arch/solaris/v10/ifaddrs.c') posix_extension.define_macros.append(('PSUTIL_SUNOS10', 1)) |