[Python-modules-commits] [python-psutil] 01/02: Imported Upstream version 4.3.0

Adrian Alves alvesadrian-guest at moszumanska.debian.org
Wed Jun 29 13:59:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

alvesadrian-guest pushed a commit to branch master
in repository python-psutil.

commit fa474c34fb6d84b9b853a702807b618f8db743db
Author: Adrian Alves <aalves at gmail.com>
Date:   Wed Jun 29 10:58:36 2016 -0300

    Imported Upstream version 4.3.0
---
 .ci/appveyor/download_exes.py     |   66 ++-
 .git-pre-commit                   |    2 +-
 CREDITS                           |    8 +
 DEVGUIDE.rst                      |   11 +-
 HISTORY.rst                       |   22 +
 Makefile                          |   62 ++-
 PKG-INFO                          |   11 +-
 README.rst                        |    9 +-
 appveyor.yml                      |    1 -
 docs/index.rst                    | 1078 +++++++++++++++++++------------------
 psutil.egg-info/PKG-INFO          |   11 +-
 psutil.egg-info/SOURCES.txt       |    1 +
 psutil/__init__.py                |    2 +-
 psutil/_common.py                 |  239 ++++----
 psutil/_compat.py                 |    3 +-
 psutil/_psbsd.py                  |  116 ++--
 psutil/_pslinux.py                |  315 ++++++-----
 psutil/_psosx.py                  |   80 ++-
 psutil/_psposix.py                |   40 +-
 psutil/_pssunos.py                |  120 +++--
 psutil/_psutil_bsd.c              |    4 +
 psutil/_psutil_windows.c          |   43 +-
 psutil/_pswindows.py              |  102 +++-
 psutil/arch/bsd/netbsd.c          |    1 +
 psutil/tests/__init__.py          |  403 ++++++++------
 psutil/tests/test_linux.py        |    9 +-
 psutil/tests/test_memory_leaks.py |    2 +-
 psutil/tests/test_posix.py        |   31 ++
 psutil/tests/test_process.py      |    8 +-
 psutil/tests/test_testutils.py    |   51 ++
 scripts/ps.py                     |   28 +-
 scripts/top.py                    |    8 +-
 32 files changed, 1778 insertions(+), 1109 deletions(-)

diff --git a/.ci/appveyor/download_exes.py b/.ci/appveyor/download_exes.py
index b7baf6b..37ebdfd 100755
--- a/.ci/appveyor/download_exes.py
+++ b/.ci/appveyor/download_exes.py
@@ -19,11 +19,43 @@ import multiprocessing
 import os
 import requests
 import shutil
+import sys
 
 from concurrent.futures import ThreadPoolExecutor
 
 
 BASE_URL = 'https://ci.appveyor.com/api'
+PY_VERSIONS = ['2.7', '3.3', '3.4', '3.5']
+
+
+def term_supports_colors(file=sys.stdout):
+    try:
+        import curses
+        assert file.isatty()
+        curses.setupterm()
+        assert curses.tigetnum("colors") > 0
+    except Exception:
+        return False
+    else:
+        return True
+
+
+if term_supports_colors():
+    def hilite(s, ok=True, bold=False):
+        """Return an highlighted version of 'string'."""
+        attr = []
+        if ok is None:  # no color
+            pass
+        elif ok:   # green
+            attr.append('32')
+        else:   # red
+            attr.append('31')
+        if bold:
+            attr.append('1')
+        return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), s)
+else:
+    def hilite(s, *a, **k):
+        return s
 
 
 def safe_makedirs(path):
@@ -47,15 +79,16 @@ def safe_rmtree(path):
 
 
 def download_file(url):
-    local_filename = url.split('/')[-1]
-    local_filename = os.path.join('dist', local_filename)
-    print(local_filename)
+    local_fname = url.split('/')[-1]
+    local_fname = os.path.join('dist', local_fname)
+    print(local_fname)
     safe_makedirs('dist')
     r = requests.get(url, stream=True)
-    with open(local_filename, 'wb') as f:
+    with open(local_fname, 'wb') as f:
         for chunk in r.iter_content(chunk_size=1024):
             if chunk:    # filter out keep-alive new chunks
                 f.write(chunk)
+    return local_fname
 
 
 def get_file_urls(options):
@@ -72,15 +105,38 @@ def get_file_urls(options):
         for item in data:
             file_url = job_url + '/' + item['fileName']
             urls.append(file_url)
+    if not urls:
+        sys.exit("no artifacts found")
     for url in sorted(urls, key=lambda x: os.path.basename(x)):
         yield url
 
 
+def rename_27_wheels():
+    # See: https://github.com/giampaolo/psutil/issues/810
+    src = 'dist/psutil-4.3.0-cp27-cp27m-win32.whl'
+    dst = 'dist/psutil-4.3.0-cp27-none-win32.whl'
+    print("rename: %s\n        %s" % (src, dst))
+    os.rename(src, dst)
+    src = 'dist/psutil-4.3.0-cp27-cp27m-win_amd64.whl'
+    dst = 'dist/psutil-4.3.0-cp27-none-win_amd64.whl'
+    print("rename: %s\n        %s" % (src, dst))
+    os.rename(src, dst)
+
+
 def main(options):
+    files = []
     safe_rmtree('dist')
     with ThreadPoolExecutor(max_workers=multiprocessing.cpu_count()) as e:
         for url in get_file_urls(options):
-            e.submit(download_file, url)
+            fut = e.submit(download_file, url)
+            files.append(fut.result())
+    # 2 exes (32 and 64 bit) and 2 wheels (32 and 64 bit) for each ver.
+    expected = len(PY_VERSIONS) * 4
+    got = len(files)
+    if expected != got:
+        print(hilite("expected %s files, got %s" % (expected, got), ok=False),
+              file=sys.stderr)
+    rename_27_wheels()
 
 
 if __name__ == '__main__':
diff --git a/.git-pre-commit b/.git-pre-commit
index 0b838d4..9938772 100755
--- a/.git-pre-commit
+++ b/.git-pre-commit
@@ -11,7 +11,7 @@ import sys
 
 def main():
     out = subprocess.check_output("git diff --cached --name-only", shell=True)
-    files = [x for x in out.split('\n') if x.endswith('.py') and
+    files = [x for x in out.split(b'\n') if x.endswith(b'.py') and
              os.path.exists(x)]
 
     for path in files:
diff --git a/CREDITS b/CREDITS
index 2d46e44..6a6c8c8 100644
--- a/CREDITS
+++ b/CREDITS
@@ -382,3 +382,11 @@ D: sample code for process USS memory.
 N: wxwright
 W: https://github.com/wxwright
 I: 776
+
+N: Farhan Khan
+E: khanzf at gmail.com
+I: 823
+
+N: Jake Omann
+E: https://github.com/jhomann
+I: 816
diff --git a/DEVGUIDE.rst b/DEVGUIDE.rst
index 691d5db..5e37483 100644
--- a/DEVGUIDE.rst
+++ b/DEVGUIDE.rst
@@ -67,8 +67,10 @@ Typical process occurring when adding a new functionality (API):
   ``psutil/_psutil_{platform}.c`` (e.g. ``psutil/_psutil_linux.c``).
 - write a generic test in ``psutil/tests/test_system.py`` or
   ``psutil/tests/test_process.py``.
-- if possible, write a cross platform test in
+- if possible, write a platform specific test in
   ``psutil/tests/test_{platform}.py`` (e.g. ``test_linux.py``).
+  This usually means testing the return value of the new feature against
+  a system CLI tool.
 - update doc in ``doc/index.py``.
 - update ``HISTORY.rst``.
 - update ``README.rst`` (if necessary).
@@ -127,7 +129,7 @@ Documentation
 - it uses `RsT syntax <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_
   and it's built with `sphinx <http://sphinx-doc.org/>`_.
 - doc can be built with ``make setup-dev-env; cd docs; make html``.
-- public is hosted on http://pythonhosted.org/psutil/.
+- public doc is hosted on http://pythonhosted.org/psutil/.
 - it is uploaded on every new release with ``make upload-doc``.
 
 =======================
@@ -139,6 +141,8 @@ These are note for myself (Giampaolo):
 - make sure all tests pass and all builds are green.
 - upload source tarball on PYPI with ``make upload-src``.
 - upload exe and wheel files for windows on PYPI with ``make upload-all``.
+  - ...or by using atrifacts hosted on AppVeyor with ``make win-download-exes``
+    and ``make win-upload-exes``,
 - upload updated doc on http://pythonhosted.org/psutil with ``make upload-doc``.
 - GIT tag the new release with ``make git-tag-release``.
 - post on psutil and python-announce mailing lists, twitter, g+, blog.
@@ -150,7 +154,8 @@ FreeBSD notes
 - setup:
 
 .. code-block:: bash
+
   $ pkg install python python3 gcc git vim screen bash
   $ chsh -s /usr/local/bin/bash user  # set bash as default shell
 
-- `/usr/src` contains the source codes for all installed CLI tools (grep in it).
\ No newline at end of file
+- ``/usr/src`` contains the source codes for all installed CLI tools (grep in it).
diff --git a/HISTORY.rst b/HISTORY.rst
index e8a6ed9..5b56cdc 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,5 +1,27 @@
 Bug tracker at https://github.com/giampaolo/psutil/issues
 
+4.3.0 - 2016-06-18
+==================
+
+**Enhancements**
+
+- #819: [Linux] different speedup improvements:
+  Process.ppid() is 20% faster
+  Process.status() is 28% faster
+  Process.name() is 25% faster
+  Process.num_threads is 20% faster on Python 3
+
+**Bug fixes**
+
+- #810: [Windows] Windows wheels are incompatible with pip 7.1.2.
+- #812: [NetBSD] fix compilation on NetBSD-5.x.
+- #823: [NetBSD] virtual_memory() raises TypeError on Python 3.
+- #829: [UNIX] psutil.disk_usage() percent field takes root reserved space
+  into account.
+- #816: [Windows] fixed net_io_counter() values wrapping after 4.3GB in
+  Windows Vista (NT 6.0) and above using 64bit values from newer win APIs.
+
+
 4.2.0 - 2016-05-14
 ==================
 
diff --git a/Makefile b/Makefile
index a20f6a8..2ec2856 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,37 @@
 # Shortcuts for various tasks (UNIX only).
-# To use a specific Python version run:
-# $ make install PYTHON=python3.3
+# To use a specific Python version run: "make install PYTHON=python3.3"
 
 # You can set these variables from the command line.
 PYTHON    = python
 TSCRIPT   = psutil/tests/runner.py
 
+# For internal use.
+PY3 := $(shell $(PYTHON) -c "import sys; print(sys.version_info[0] == 3)")
+PYVER := $(shell $(PYTHON) -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
+
+DEPS = coverage \
+	flake8 \
+	ipdb \
+	nose \
+	pep8 \
+	pyflakes \
+	requests \
+	sphinx \
+	sphinx-pypi-upload
+ifeq ($(PYVER), 2.6)
+	DEPS += unittest2 ipaddress futures mock==1.0.1
+endif
+ifeq ($(PYVER), 2.7)
+	DEPS += unittest2 ipaddress futures mock
+endif
+
+ifeq ($(PY3), True)
+	URLLIB_IMPORTS := from urllib.request import urlopen, ssl
+else
+	URLLIB_IMPORTS := from urllib2 import urlopen, ssl
+endif
+
+
 all: test
 
 clean:
@@ -33,35 +59,23 @@ build: clean
 	@# this directory.
 	$(PYTHON) setup.py build_ext -i
 
+install: build
+	$(PYTHON) setup.py develop --user
+
+uninstall:
+	cd ..; $(PYTHON) -m pip uninstall -y -v psutil
+
 # useful deps which are nice to have while developing / testing
 setup-dev-env: install-git-hooks
-	python -c  "import urllib2, ssl; \
+	$(PYTHON) -c "$(URLLIB_IMPORTS); \
 				context = ssl._create_unverified_context() if hasattr(ssl, '_create_unverified_context') else None; \
 				kw = dict(context=context) if context else {}; \
-				r = urllib2.urlopen('https://bootstrap.pypa.io/get-pip.py', **kw); \
-				open('/tmp/get-pip.py', 'w').write(r.read());"
+				r = urlopen('https://bootstrap.pypa.io/get-pip.py', **kw); \
+				open('/tmp/get-pip.py', 'w').write(str(r.read()));"
 	$(PYTHON) /tmp/get-pip.py --user
 	rm /tmp/get-pip.py
 	$(PYTHON) -m pip install --user --upgrade pip
-	$(PYTHON) -m pip install --user --upgrade \
-		coverage  \
-		flake8 \
-		ipaddress \
-		ipdb \
-		mock==1.0.1 \
-		nose \
-		pep8 \
-		pyflakes \
-		requests \
-		sphinx \
-		sphinx-pypi-upload \
-		unittest2 \
-
-install: build
-	$(PYTHON) setup.py develop --user
-
-uninstall:
-	cd ..; $(PYTHON) -m pip uninstall -y -v psutil
+	$(PYTHON) -m pip install --user --upgrade $(DEPS)
 
 test: install
 	$(PYTHON) $(TSCRIPT)
diff --git a/PKG-INFO b/PKG-INFO
index 1313744..f5ab9e9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: psutil
-Version: 4.2.0
+Version: 4.3.0
 Summary: psutil is a cross-platform library for retrieving information onrunning processes and system utilization (CPU, memory, disks, network)in Python.
 Home-page: https://github.com/giampaolo/psutil
 Author: Giampaolo Rodola
@@ -10,11 +10,11 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
             :target: https://pypi.python.org/pypi/psutil#downloads
             :alt: Downloads this month
         
-        .. image:: https://api.travis-ci.org/giampaolo/psutil.png?branch=master
+        .. image:: https://img.shields.io/travis/giampaolo/psutil/master.svg?maxAge=3600&label=Linux%20/%20OSX
             :target: https://travis-ci.org/giampaolo/psutil
             :alt: Linux tests (Travis)
         
-        .. image:: https://ci.appveyor.com/api/projects/status/qdwvw7v1t915ywr5/branch/master?svg=true
+        .. image:: https://img.shields.io/appveyor/ci/giampaolo/psutil/master.svg?maxAge=3600&label=Windows
             :target: https://ci.appveyor.com/project/giampaolo/psutil
             :alt: Windows tests (Appveyor)
         
@@ -22,7 +22,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
             :target: https://coveralls.io/github/giampaolo/psutil?branch=master
             :alt: Test coverage (coverall.io)
         
-        .. image:: https://img.shields.io/pypi/v/psutil.svg
+        .. image:: https://img.shields.io/pypi/v/psutil.svg?label=version
             :target: https://pypi.python.org/pypi/psutil/
             :alt: Latest version
         
@@ -85,6 +85,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
          * https://github.com/nicolargo/glances
          * https://github.com/google/grr
          * https://github.com/Jahaja/psdash
+         * https://github.com/giampaolo/psutil/tree/master/scripts
         
         ==============
         Example usages
@@ -386,6 +387,8 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
         Timeline
         ========
         
+        - 2016-06-18: `psutil-4.3.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-4.3.0.tar.gz>`_
+        - 2016-05-15: `psutil-4.2.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-4.2.0.tar.gz>`_
         - 2016-03-12: `psutil-4.1.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-4.1.0.tar.gz>`_
         - 2016-02-17: `psutil-4.0.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-4.0.0.tar.gz>`_
         - 2016-01-20: `psutil-3.4.2.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.2.tar.gz>`_
diff --git a/README.rst b/README.rst
index ffe3514..826d989 100644
--- a/README.rst
+++ b/README.rst
@@ -2,11 +2,11 @@
     :target: https://pypi.python.org/pypi/psutil#downloads
     :alt: Downloads this month
 
-.. image:: https://api.travis-ci.org/giampaolo/psutil.png?branch=master
+.. image:: https://img.shields.io/travis/giampaolo/psutil/master.svg?maxAge=3600&label=Linux%20/%20OSX
     :target: https://travis-ci.org/giampaolo/psutil
     :alt: Linux tests (Travis)
 
-.. image:: https://ci.appveyor.com/api/projects/status/qdwvw7v1t915ywr5/branch/master?svg=true
+.. image:: https://img.shields.io/appveyor/ci/giampaolo/psutil/master.svg?maxAge=3600&label=Windows
     :target: https://ci.appveyor.com/project/giampaolo/psutil
     :alt: Windows tests (Appveyor)
 
@@ -14,7 +14,7 @@
     :target: https://coveralls.io/github/giampaolo/psutil?branch=master
     :alt: Test coverage (coverall.io)
 
-.. image:: https://img.shields.io/pypi/v/psutil.svg
+.. image:: https://img.shields.io/pypi/v/psutil.svg?label=version
     :target: https://pypi.python.org/pypi/psutil/
     :alt: Latest version
 
@@ -77,6 +77,7 @@ See also:
  * https://github.com/nicolargo/glances
  * https://github.com/google/grr
  * https://github.com/Jahaja/psdash
+ * https://github.com/giampaolo/psutil/tree/master/scripts
 
 ==============
 Example usages
@@ -378,6 +379,8 @@ http://groups.google.com/group/psutil/
 Timeline
 ========
 
+- 2016-06-18: `psutil-4.3.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-4.3.0.tar.gz>`_
+- 2016-05-15: `psutil-4.2.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-4.2.0.tar.gz>`_
 - 2016-03-12: `psutil-4.1.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-4.1.0.tar.gz>`_
 - 2016-02-17: `psutil-4.0.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-4.0.0.tar.gz>`_
 - 2016-01-20: `psutil-3.4.2.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.2.tar.gz>`_
diff --git a/appveyor.yml b/appveyor.yml
index 52e56ba..5299720 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -64,7 +64,6 @@ init:
 install:
   - "powershell .ci\\appveyor\\install.ps1"
   # - ps: (new-object net.webclient).DownloadFile('https://raw.github.com/pypa/pip/master/contrib/get-pip.py', 'C:/get-pip.py')
-  - "%WITH_COMPILER% %PYTHON%/python.exe -m pip install --upgrade --user setuptools pip"
   - "%WITH_COMPILER% %PYTHON%/python.exe -m pip --version"
   - "%WITH_COMPILER% %PYTHON%/python.exe -m pip install --upgrade --user unittest2 ipaddress pypiwin32 wmi wheel"
   - "%WITH_COMPILER% %PYTHON%/python.exe -m pip freeze"
diff --git a/docs/index.rst b/docs/index.rst
index 1873366..a0d80b7 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -106,7 +106,6 @@ CPU
     >>>
 
   .. warning::
-
     the first time this function is called with *interval* = ``0.0`` or ``None``
     it will return a meaningless ``0.0`` value which you are supposed to
     ignore.
@@ -120,28 +119,27 @@ CPU
   *percpu* arguments have the same meaning as in :func:`cpu_percent()`.
 
   .. warning::
-
     the first time this function is called with *interval* = ``0.0`` or
     ``None`` it will return a meaningless ``0.0`` value which you are supposed
     to ignore.
 
-  .. versionchanged:: 4.1.0 two new *interrupt* and *dpc* fields are returned
-     on Windows.
+  .. versionchanged::
+    4.1.0 two new *interrupt* and *dpc* fields are returned on Windows.
 
 .. function:: cpu_count(logical=True)
 
-    Return the number of logical CPUs in the system (same as
-    `os.cpu_count() <http://docs.python.org/3/library/os.html#os.cpu_count>`__
-    in Python 3.4).
-    If *logical* is ``False`` return the number of physical cores only (hyper
-    thread CPUs are excluded). Return ``None`` if undetermined.
+  Return the number of logical CPUs in the system (same as
+  `os.cpu_count() <http://docs.python.org/3/library/os.html#os.cpu_count>`__
+  in Python 3.4).
+  If *logical* is ``False`` return the number of physical cores only (hyper
+  thread CPUs are excluded). Return ``None`` if undetermined.
 
-      >>> import psutil
-      >>> psutil.cpu_count()
-      4
-      >>> psutil.cpu_count(logical=False)
-      2
-      >>>
+    >>> import psutil
+    >>> psutil.cpu_count()
+    4
+    >>> psutil.cpu_count(logical=False)
+    2
+    >>>
 
 .. function:: cpu_stats()
 
@@ -207,16 +205,19 @@ Memory
   See `scripts/meminfo.py <https://github.com/giampaolo/psutil/blob/master/scripts/meminfo.py>`__
   script providing an example on how to convert bytes in a human readable form.
 
-    >>> import psutil
-    >>> mem = psutil.virtual_memory()
-    >>> mem
-    svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304)
-    >>>
-    >>> THRESHOLD = 100 * 1024 * 1024  # 100MB
-    >>> if mem.available <= THRESHOLD:
-    ...     print("warning")
-    ...
-    >>>
+  .. note:: if you just want to know how much physical memory is left in a
+    cross platform fashion simply rely on the **available** field.
+
+  >>> import psutil
+  >>> mem = psutil.virtual_memory()
+  >>> mem
+  svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304)
+  >>>
+  >>> THRESHOLD = 100 * 1024 * 1024  # 100MB
+  >>> if mem.available <= THRESHOLD:
+  ...     print("warning")
+  ...
+  >>>
 
   .. versionchanged:: 4.2.0 added *shared* metrics on Linux.
 
@@ -275,20 +276,29 @@ Disks
   **total**, **used** and **free** space expressed in bytes, plus the
   **percentage** usage.
   `OSError <http://docs.python.org/3/library/exceptions.html#OSError>`__ is
-  raised if *path* does not exist. See
-  `scripts/disk_usage.py <https://github.com/giampaolo/psutil/blob/master/scripts/disk_usage.py>`__
-  script providing an example usage. Starting from
-  `Python 3.3 <http://bugs.python.org/issue12442>`__  this is also
-  available as
+  raised if *path* does not exist.
+  Starting from `Python 3.3 <http://bugs.python.org/issue12442>`__  this is
+  also available as
   `shutil.disk_usage() <http://docs.python.org/3/library/shutil.html#shutil.disk_usage>`__.
-  See
-  `disk_usage.py <https://github.com/giampaolo/psutil/blob/master/scripts/disk_usage.py>`__
-  script providing an example usage.
+  See `disk_usage.py <https://github.com/giampaolo/psutil/blob/master/scripts/disk_usage.py>`__ script providing an example usage.
 
     >>> import psutil
     >>> psutil.disk_usage('/')
     sdiskusage(total=21378641920, used=4809781248, free=15482871808, percent=22.5)
 
+  .. note::
+    UNIX usually reserves 5% of the total disk space for the root user.
+    *total* and *used* fields on UNIX refer to the overall total and used
+    space, whereas *free* represents the space available for the **user** and
+    *percent* represents the **user** utilization (see
+    `source code <https://github.com/giampaolo/psutil/blob/3dea30d583b8c1275057edb1b3b720813b4d0f60/psutil/_psposix.py#L123>`__).
+    That is why *percent* value may look 5% bigger than what you would expect
+    it to be.
+    Also note that both 4 values match "df" cmdline utility.
+
+  .. versionchanged::
+    4.3.0 *percent* value takes root reserved space into account.
+
 .. function:: disk_io_counters(perdisk=False)
 
   Return system-wide disk I/O statistics as a namedtuple including the
@@ -327,10 +337,18 @@ Disks
      'sda2': sdiskio(read_count=18707, write_count=8830, read_bytes=6060, write_bytes=3443, read_time=24585, write_time=1572),
      'sdb1': sdiskio(read_count=161, write_count=0, read_bytes=786432, write_bytes=0, read_time=44, write_time=0)}
 
-  .. versionchanged:: 4.0.0 added *busy_time* (Linux, FreeBSD),
-     *read_merged_count* and *write_merged_count* (Linux) fields.
-  .. versionchanged:: 4.0.0 NetBSD no longer has *read_time* and *write_time*
-     fields.
+  .. warning::
+    on some systems such as Linux, on a very busy or long-lived system these
+    numbers may wrap (restart from zero), see
+    `issues #802 <https://github.com/giampaolo/psutil/issues/802>`__.
+    Applications should be prepared to deal with that.
+
+  .. versionchanged::
+    4.0.0 added *busy_time* (Linux, FreeBSD), *read_merged_count* and
+    *write_merged_count* (Linux) fields.
+
+  .. versionchanged::
+    4.0.0 NetBSD no longer has *read_time* and *write_time* fields.
 
 Network
 -------
@@ -364,6 +382,12 @@ Network
     {'lo': snetio(bytes_sent=547971, bytes_recv=547971, packets_sent=5075, packets_recv=5075, errin=0, errout=0, dropin=0, dropout=0),
     'wlan0': snetio(bytes_sent=13921765, bytes_recv=62162574, packets_sent=79097, packets_recv=89648, errin=0, errout=0, dropin=0, dropout=0)}
 
+  .. warning::
+    on some systems such as Linux, on a very busy or long-lived system these
+    numbers may wrap (restart from zero), see
+    `issues #802 <https://github.com/giampaolo/psutil/issues/802>`__.
+    Applications should be prepared to deal with that.
+
 .. function:: net_connections(kind='inet')
 
   Return system-wide socket connections as a list of namedtuples.
@@ -442,9 +466,12 @@ Network
      pconn(fd=-1, family=<AddressFamily.AF_INET: 2>, type=<SocketType.SOCK_STREAM: 1>, laddr=('10.0.0.1', 51314), raddr=('72.14.234.83', 443), status='SYN_SENT', pid=None)
      ...]
 
-  .. note:: (OSX) :class:`psutil.AccessDenied` is always raised unless running
-     as root (lsof does the same).
-  .. note:: (Solaris) UNIX sockets are not supported.
+  .. note::
+    (OSX) :class:`psutil.AccessDenied` is always raised unless running as root
+    (lsof does the same).
+
+  .. note::
+    (Solaris) UNIX sockets are not supported.
 
   .. versionadded:: 2.1.0
 
@@ -488,15 +515,18 @@ Network
   See also `scripts/ifconfig.py <https://github.com/giampaolo/psutil/blob/master/scripts/ifconfig.py>`__
   for an example application.
 
-  .. note:: if you're interested in others families (e.g. AF_BLUETOOTH) you can
-    use the more powerful `netifaces <https://pypi.python.org/pypi/netifaces/>`__
+  .. note::
+    if you're interested in others families (e.g. AF_BLUETOOTH) you can use
+    the more powerful `netifaces <https://pypi.python.org/pypi/netifaces/>`__
     extension.
 
-  .. note:: you can have more than one address of the same family associated
-    with each interface (that's why dict values are lists).
+  .. note::
+    you can have more than one address of the same family associated with each
+    interface (that's why dict values are lists).
 
-  .. note:: *netmask*, *broadcast* and *ptp* are not supported on Windows and
-    are set to ``None``.
+  .. note::
+    *netmask*, *broadcast* and *ptp* are not supported on Windows and are set
+    to ``None``.
 
   .. versionadded:: 3.0.0
 
@@ -641,32 +671,32 @@ Exceptions
 
 .. class:: NoSuchProcess(pid, name=None, msg=None)
 
-   Raised by :class:`Process` class methods when no process with the given
-   *pid* is found in the current process list or when a process no longer
-   exists. "name" is the name the process had before disappearing
-   and gets set only if :meth:`Process.name()` was previosly called.
+  Raised by :class:`Process` class methods when no process with the given
+  pid* is found in the current process list or when a process no longer
+  exists. "name" is the name the process had before disappearing
+  and gets set only if :meth:`Process.name()` was previosly called.
 
 .. class:: ZombieProcess(pid, name=None, ppid=None, msg=None)
 
-   This may be raised by :class:`Process` class methods when querying a zombie
-   process on UNIX (Windows doesn't have zombie processes). Depending on the
-   method called the OS may be able to succeed in retrieving the process
-   information or not.
-   Note: this is a subclass of :class:`NoSuchProcess` so if you're not
-   interested in retrieving zombies (e.g. when using :func:`process_iter()`)
-   you can ignore this exception and just catch :class:`NoSuchProcess`.
+  This may be raised by :class:`Process` class methods when querying a zombie
+  process on UNIX (Windows doesn't have zombie processes). Depending on the
+  method called the OS may be able to succeed in retrieving the process
+  information or not.
+  Note: this is a subclass of :class:`NoSuchProcess` so if you're not
+  interested in retrieving zombies (e.g. when using :func:`process_iter()`)
+  you can ignore this exception and just catch :class:`NoSuchProcess`.
 
   .. versionadded:: 3.0.0
 
 .. class:: AccessDenied(pid=None, name=None, msg=None)
 
-    Raised by :class:`Process` class methods when permission to perform an
-    action is denied. "name" is the name of the process (may be ``None``).
+  Raised by :class:`Process` class methods when permission to perform an
+  action is denied. "name" is the name of the process (may be ``None``).
 
 .. class:: TimeoutExpired(seconds, pid=None, name=None, msg=None)
 
-    Raised by :meth:`Process.wait` if timeout expires and process is still
-    alive.
+  Raised by :meth:`Process.wait` if timeout expires and process is still
+  alive.
 
 Process class
 -------------
@@ -712,154 +742,155 @@ Process class
 
   .. attribute:: pid
 
-     The process PID.
+    The process PID.
 
   .. method:: ppid()
 
-     The process parent pid.  On Windows the return value is cached after first
-     call.
+    The process parent pid.  On Windows the return value is cached after first
+    call.
 
   .. method:: name()
 
-     The process name.
+    The process name.
 
   .. method:: exe()
 
-     The process executable as an absolute path.
-     On some systems this may also be an empty string.
-     The return value is cached after first call.
+    The process executable as an absolute path.
+    On some systems this may also be an empty string.
+    The return value is cached after first call.
 
   .. method:: cmdline()
 
-     The command line this process has been called with.
+    The command line this process has been called with.
 
   .. method:: environ()
 
-     The environment variables of the process as a dict.  Note: this might not
-     reflect changes made after the process started.
+    The environment variables of the process as a dict.  Note: this might not
+    reflect changes made after the process started.
 
-     Availability: Linux, OSX, Windows
+    Availability: Linux, OSX, Windows
 
-     .. versionadded:: 4.0.0
+    .. versionadded:: 4.0.0
 
   .. method:: create_time()
 
-     The process creation time as a floating point number expressed in seconds
-     since the epoch, in
-     `UTC <http://en.wikipedia.org/wiki/Coordinated_universal_time>`__.
-     The return value is cached after first call.
+    The process creation time as a floating point number expressed in seconds
+    since the epoch, in
+    `UTC <http://en.wikipedia.org/wiki/Coordinated_universal_time>`__.
+    The return value is cached after first call.
 
-        >>> import psutil, datetime
-        >>> p = psutil.Process()
-        >>> p.create_time()
-        1307289803.47
-        >>> datetime.datetime.fromtimestamp(p.create_time()).strftime("%Y-%m-%d %H:%M:%S")
-        '2011-03-05 18:03:52'
+      >>> import psutil, datetime
+      >>> p = psutil.Process()
+      >>> p.create_time()
+      1307289803.47
+      >>> datetime.datetime.fromtimestamp(p.create_time()).strftime("%Y-%m-%d %H:%M:%S")
+      '2011-03-05 18:03:52'
 
   .. method:: as_dict(attrs=None, ad_value=None)
 
-     Utility method retrieving multiple process information as a dictionary.
-     If *attrs* is specified it must be a list of strings reflecting available
-     :class:`Process` class's attribute names (e.g. ``['cpu_times', 'name']``),
-     else all public (read only) attributes are assumed. *ad_value* is the
-     value which gets assigned to a dict key in case :class:`AccessDenied`
-     or :class:`ZombieProcess` exception is raised when retrieving that
-     particular process information.
+    Utility method retrieving multiple process information as a dictionary.
+    If *attrs* is specified it must be a list of strings reflecting available
+    :class:`Process` class's attribute names (e.g. ``['cpu_times', 'name']``),
+    else all public (read only) attributes are assumed. *ad_value* is the
+    value which gets assigned to a dict key in case :class:`AccessDenied`
+    or :class:`ZombieProcess` exception is raised when retrieving that
+    particular process information.
 
-        >>> import psutil
-        >>> p = psutil.Process()
-        >>> p.as_dict(attrs=['pid', 'name', 'username'])
-        {'username': 'giampaolo', 'pid': 12366, 'name': 'python'}
+      >>> import psutil
+      >>> p = psutil.Process()
+      >>> p.as_dict(attrs=['pid', 'name', 'username'])
+      {'username': 'giampaolo', 'pid': 12366, 'name': 'python'}
 
-     .. versionchanged:: 3.0.0 *ad_value* is used also when incurring into
-        :class:`ZombieProcess` exception, not only :class:`AccessDenied`
+    .. versionchanged::
+      3.0.0 *ad_value* is used also when incurring into
+      :class:`ZombieProcess` exception, not only :class:`AccessDenied`
 
   .. method:: parent()
 
-     Utility method which returns the parent process as a :class:`Process`
-     object preemptively checking whether PID has been reused. If no parent
-     PID is known return ``None``.
+    Utility method which returns the parent process as a :class:`Process`
+    object preemptively checking whether PID has been reused. If no parent
+    PID is known return ``None``.
 
   .. method:: status()
 
-     The current process status as a string. The returned string is one of the
-     :data:`psutil.STATUS_*<psutil.STATUS_RUNNING>` constants.
+    The current process status as a string. The returned string is one of the
+    :data:`psutil.STATUS_*<psutil.STATUS_RUNNING>` constants.
 
   .. method:: cwd()
 
-     The process current working directory as an absolute path.
+    The process current working directory as an absolute path.
 
   .. method:: username()
 
-     The name of the user that owns the process. On UNIX this is calculated by
-     using real process uid.
+    The name of the user that owns the process. On UNIX this is calculated by
+    using real process uid.
 
   .. method:: uids()
 
-     The real, effective and saved user ids of this process as a
-     namedtuple. This is the same as
-     `os.getresuid() <http://docs.python.org//library/os.html#os.getresuid>`__
-     but can be used for any process PID.
+    The real, effective and saved user ids of this process as a
+    namedtuple. This is the same as
+    `os.getresuid() <http://docs.python.org//library/os.html#os.getresuid>`__
+    but can be used for any process PID.
 
-     Availability: UNIX
+    Availability: UNIX
 
   .. method:: gids()
 
-     The real, effective and saved group ids of this process as a
-     namedtuple. This is the same as
-     `os.getresgid() <http://docs.python.org//library/os.html#os.getresgid>`__
-     but can be used for any process PID.
+    The real, effective and saved group ids of this process as a
+    namedtuple. This is the same as
+    `os.getresgid() <http://docs.python.org//library/os.html#os.getresgid>`__
+    but can be used for any process PID.
 
-     Availability: UNIX
+    Availability: UNIX
 
   .. method:: terminal()
 
-     The terminal associated with this process, if any, else ``None``. This is
-     similar to "tty" command but can be used for any process PID.
+    The terminal associated with this process, if any, else ``None``. This is
+    similar to "tty" command but can be used for any process PID.
 
-     Availability: UNIX
+    Availability: UNIX
 
   .. method:: nice(value=None)
 
-     Get or set process
-     `niceness <blogs.techrepublic.com.com/opensource/?p=140>`__ (priority).
-     On UNIX this is a number which usually goes from ``-20`` to ``20``.
-     The higher the nice value, the lower the priority of the process.
-
-        >>> import psutil
-        >>> p = psutil.Process()
-        >>> p.nice(10)  # set
-        >>> p.nice()  # get
-        10
-        >>>
-
-     Starting from `Python 3.3 <http://bugs.python.org/issue10784>`__ this
-     functionality is also available as
-     `os.getpriority() <http://docs.python.org/3/library/os.html#os.getpriority>`__
-     and
-     `os.setpriority() <http://docs.python.org/3/library/os.html#os.setpriority>`__
-     (UNIX only).
-     On Windows this is implemented via
-     `GetPriorityClass <http://msdn.microsoft.com/en-us/library/ms683211(v=vs.85).aspx>`__
-     and `SetPriorityClass <http://msdn.microsoft.com/en-us/library/ms686219(v=vs.85).aspx>`__
-     Windows APIs and *value* is one of the
-     :data:`psutil.*_PRIORITY_CLASS <psutil.ABOVE_NORMAL_PRIORITY_CLASS>`
-     constants reflecting the MSDN documentation.
-     Example which increases process priority on Windows:
-
-        >>> p.nice(psutil.HIGH_PRIORITY_CLASS)
+    Get or set process
+    `niceness <blogs.techrepublic.com.com/opensource/?p=140>`__ (priority).
+    On UNIX this is a number which usually goes from ``-20`` to ``20``.
+    The higher the nice value, the lower the priority of the process.
+
+      >>> import psutil
+      >>> p = psutil.Process()
+      >>> p.nice(10)  # set
+      >>> p.nice()  # get
+      10
+      >>>
+
+    Starting from `Python 3.3 <http://bugs.python.org/issue10784>`__ this
+    functionality is also available as
+    `os.getpriority() <http://docs.python.org/3/library/os.html#os.getpriority>`__
+    and
+    `os.setpriority() <http://docs.python.org/3/library/os.html#os.setpriority>`__
+    (UNIX only).
+    On Windows this is implemented via
+    `GetPriorityClass <http://msdn.microsoft.com/en-us/library/ms683211(v=vs.85).aspx>`__
+    and `SetPriorityClass <http://msdn.microsoft.com/en-us/library/ms686219(v=vs.85).aspx>`__
+    Windows APIs and *value* is one of the
+    :data:`psutil.*_PRIORITY_CLASS <psutil.ABOVE_NORMAL_PRIORITY_CLASS>`
+    constants reflecting the MSDN documentation.
+    Example which increases process priority on Windows:
+
+      >>> p.nice(psutil.HIGH_PRIORITY_CLASS)
 
   .. method:: ionice(ioclass=None, value=None)
 
-     Get or set
-     `process I/O niceness <http://friedcpu.wordpress.com/2007/07/17/why-arent-you-using-ionice-yet/>`__ (priority).
-     On Linux *ioclass* is one of the
-     :data:`psutil.IOPRIO_CLASS_*<psutil.IOPRIO_CLASS_NONE>` constants.
-     *value* is a number which goes from  ``0`` to ``7``. The higher the value,
-     the lower the I/O priority of the process. On Windows only *ioclass* is
-     used and it can be set to ``2`` (normal), ``1`` (low) or ``0`` (very low).
-     The example below sets IDLE priority class for the current process,
-     meaning it will only get I/O time when no other process needs the disk:
+    Get or set
+    `process I/O niceness <http://friedcpu.wordpress.com/2007/07/17/why-arent-you-using-ionice-yet/>`__ (priority).
+    On Linux *ioclass* is one of the
+    :data:`psutil.IOPRIO_CLASS_*<psutil.IOPRIO_CLASS_NONE>` constants.
+    *value* is a number which goes from  ``0`` to ``7``. The higher the value,
+    the lower the I/O priority of the process. On Windows only *ioclass* is
+    used and it can be set to ``2`` (normal), ``1`` (low) or ``0`` (very low).
+    The example below sets IDLE priority class for the current process,
+    meaning it will only get I/O time when no other process needs the disk:
 
       >>> import psutil
       >>> p = psutil.Process()
@@ -868,26 +899,27 @@ Process class
       pionice(ioclass=<IOPriority.IOPRIO_CLASS_IDLE: 3>, value=0)
       >>>
 
-     On Windows only *ioclass* is used and it can be set to ``2`` (normal),
-     ``1`` (low) or ``0`` (very low).
+    On Windows only *ioclass* is used and it can be set to ``2`` (normal),
+    ``1`` (low) or ``0`` (very low).
 
-     Availability: Linux and Windows > Vista
+    Availability: Linux and Windows > Vista
 
-     .. versionchanged:: 3.0.0 on >= Python 3.4 the returned ``ioclass``
-        constant is an `enum <https://docs.python.org/3/library/enum.html#module-enum>`__
-        instead of a plain integer.
+    .. versionchanged::
+      3.0.0 on Python >= 3.4 the returned ``ioclass`` constant is an
+      `enum <https://docs.python.org/3/library/enum.html#module-enum>`__
+      instead of a plain integer.
 
   .. method:: rlimit(resource, limits=None)
 
-     Get or set process resource limits (see
-     `man prlimit <http://linux.die.net/man/2/prlimit>`__). *resource* is one of
-     the :data:`psutil.RLIMIT_* <psutil.RLIMIT_INFINITY>` constants.
-     *limits* is a ``(soft, hard)`` tuple.
-     This is the same as `resource.getrlimit() <http://docs.python.org/library/resource.html#resource.getrlimit>`__
-     and `resource.setrlimit() <http://docs.python.org/library/resource.html#resource.setrlimit>`__
-     but can be used for any process PID, not only
-     `os.getpid() <http://docs.python.org/library/os.html#os.getpid>`__.
-     Example:
+    Get or set process resource limits (see
+    `man prlimit <http://linux.die.net/man/2/prlimit>`__). *resource* is one
+    of the :data:`psutil.RLIMIT_* <psutil.RLIMIT_INFINITY>` constants.
+    *limits* is a ``(soft, hard)`` tuple.
+    This is the same as `resource.getrlimit() <http://docs.python.org/library/resource.html#resource.getrlimit>`__
+    and `resource.setrlimit() <http://docs.python.org/library/resource.html#resource.setrlimit>`__
+    but can be used for any process PID, not only
+    `os.getpid() <http://docs.python.org/library/os.html#os.getpid>`__.
+    Example:
 
       >>> import psutil
       >>> p = psutil.Process()
@@ -900,79 +932,79 @@ Process class
       (1024, 1024)
       >>>
 
-     Availability: Linux
+    Availability: Linux
 
   .. method:: io_counters()
 
... 3531 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-psutil.git



More information about the Python-modules-commits mailing list