[Python-modules-commits] [python-psutil] 01/08: Import python-psutil_5.4.2.orig.tar.gz

Sandro Tosi morph at moszumanska.debian.org
Mon Dec 11 02:14:02 UTC 2017


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

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

commit 714e49e4918a502df13c6e90da062acdaec164d3
Author: Sandro Tosi <morph at debian.org>
Date:   Sun Dec 10 09:25:58 2017 -0500

    Import python-psutil_5.4.2.orig.tar.gz
---
 CREDITS                            |   6 +-
 DEVGUIDE.rst                       |  58 ++++++---
 HISTORY.rst                        |  26 ++++
 INSTALL.rst                        |  59 +++++----
 MANIFEST.in                        |   1 +
 Makefile                           |  57 ++++----
 PKG-INFO                           |   5 +-
 README.rst                         |   3 +-
 docs/index.rst                     |  25 +++-
 psutil.egg-info/PKG-INFO           |   5 +-
 psutil.egg-info/SOURCES.txt        |   1 +
 psutil/__init__.py                 | 261 +++++++++++++------------------------
 psutil/_common.py                  |   4 +-
 psutil/_exceptions.py              |  94 +++++++++++++
 psutil/_psaix.py                   |  17 +--
 psutil/_psbsd.py                   |  14 +-
 psutil/_pslinux.py                 |  50 +++++--
 psutil/_psosx.py                   |  55 ++++++--
 psutil/_psposix.py                 |  12 +-
 psutil/_pssunos.py                 |  14 +-
 psutil/_psutil_aix.c               |   8 +-
 psutil/_psutil_bsd.c               |   8 +-
 psutil/_psutil_common.c            |  99 ++++++++------
 psutil/_psutil_common.h            |  14 +-
 psutil/_psutil_linux.c             |   8 +-
 psutil/_psutil_osx.c               | 141 +++++++++++++++++---
 psutil/_psutil_posix.c             |  15 ++-
 psutil/_psutil_sunos.c             |   8 +-
 psutil/_psutil_windows.c           | 149 +++++++++++++--------
 psutil/_pswindows.py               |  11 +-
 psutil/arch/freebsd/proc_socks.c   |   2 +-
 psutil/arch/freebsd/specific.c     |  14 +-
 psutil/arch/netbsd/specific.c      |  10 +-
 psutil/arch/openbsd/specific.c     |  10 +-
 psutil/arch/osx/process_info.c     |   8 +-
 psutil/arch/windows/process_info.c |  10 +-
 psutil/tests/__init__.py           |  54 +++++---
 psutil/tests/test_aix.py           |   0
 psutil/tests/test_connections.py   |   2 +
 psutil/tests/test_contracts.py     |  24 +++-
 psutil/tests/test_linux.py         |  20 +++
 psutil/tests/test_misc.py          |  27 ++--
 psutil/tests/test_osx.py           |  13 ++
 psutil/tests/test_posix.py         |  11 +-
 psutil/tests/test_process.py       |  48 ++++---
 psutil/tests/test_system.py        |   4 +-
 scripts/internal/print_announce.py |   7 +-
 scripts/internal/winmake.py        |  42 ++++--
 48 files changed, 968 insertions(+), 566 deletions(-)

diff --git a/CREDITS b/CREDITS
index 890b822..d215c60 100644
--- a/CREDITS
+++ b/CREDITS
@@ -57,7 +57,7 @@ W: http://www.jayloden.com
 
 N: Arnon Yaari (wiggin15)
 W: https://github.com/wiggin15
-I: 517, 607, 610, 1131, 1123, 1130, 1154, 1164
+I: 517, 607, 610, 1131, 1123, 1130, 1154, 1164, 1174, 1177
 
 N: Jeff Tang
 W: https://github.com/mrjefftang
@@ -511,3 +511,7 @@ I: 1159, 1160, 1161
 N: Matthew Long
 W: https://github.com/matray
 I: 1167
+
+N: janderbrain
+W: https://github.com/janderbrain
+I: 1169
diff --git a/DEVGUIDE.rst b/DEVGUIDE.rst
index 2d0af7f..2d48ced 100644
--- a/DEVGUIDE.rst
+++ b/DEVGUIDE.rst
@@ -4,17 +4,23 @@ Setup and running tests
 
 If you plan on hacking on psutil this is what you're supposed to do first:
 
-- clone the GIT repository::
+- clone the GIT repository:
+
+.. code-block:: bash
 
   $ git clone git at github.com:giampaolo/psutil.git
 
-- install test deps and GIT hooks::
+- install test deps and GIT hooks:
+
+.. code-block:: bash
+
+  make setup-dev-env
 
-  $ make setup-dev-env
+- run tests:
 
-- run tests::
+.. code-block:: bash
 
-  $ make test
+  make test
 
 - bear in mind that ``make``
   (see `Makefile <https://github.com/giampaolo/psutil/blob/master/Makefile>`_)
@@ -38,34 +44,46 @@ Coding style
 Makefile
 ========
 
-Some useful make commands::
+Some useful make commands:
+
+.. code-block:: bash
 
-  $ make install        # install
-  $ make setup-dev-env  # install useful dev libs (pyflakes, unittest2, etc.)
-  $ make test           # run unit tests
-  $ make test-memleaks  # run memory leak tests
-  $ make test-coverage  # run test coverage
-  $ make flake8         # run PEP8 linter
+    make install        # install
+    make setup-dev-env  # install useful dev libs (pyflakes, unittest2, etc.)
+    make test           # run unit tests
+    make test-memleaks  # run memory leak tests
+    make test-coverage  # run test coverage
+    make flake8         # run PEP8 linter
 
 There are some differences between ``make`` on UNIX and Windows.
-For instance, to run a specific Python version. On UNIX::
+For instance, to run a specific Python version. On UNIX:
+
+.. code-block:: bash
 
     make test PYTHON=python3.5
 
-On Windows::
+On Windows:
+
+.. code-block:: bat
 
     set PYTHON=C:\python35\python.exe && make test
 
-    # ...or:
+...or:
+
+.. code-block:: bat
 
     make -p 35 test
 
 If you want to modify psutil and run a script on the fly which uses it do
-(on UNIX)::
+(on UNIX):
+
+.. code-block:: bash
 
     make test TSCRIPT=foo.py
 
-On Windows::
+On Windows:
+
+.. code-block:: bat
 
     set TSCRIPT=foo.py && make test
 
@@ -75,7 +93,7 @@ Adding a new feature
 
 Usually the files involved when adding a new functionality are:
 
-.. code-block:: plain
+.. code-block:: bash
 
     psutil/__init__.py                   # main psutil namespace
     psutil/_ps{platform}.py              # python platform wrapper
@@ -185,7 +203,7 @@ FreeBSD notes
 
 .. code-block:: bash
 
-  $ pkg install python python3 gcc git vim screen bash
-  $ chsh -s /usr/local/bin/bash user  # set bash as default shell
+    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).
diff --git a/HISTORY.rst b/HISTORY.rst
index 8693bcf..b28e52b 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,5 +1,31 @@
 *Bug tracker at https://github.com/giampaolo/psutil/issues*
 
+5.4.2
+=====
+
+*2017-12-07*
+
+**Enhancements**
+
+- 1173_: introduced PSUTIL_DEBUG environment variable which can be set in order
+  to print useful debug messages on stderr (useful in case of nasty errors).
+- 1177_: added support for sensors_battery() on OSX.  (patch by Arnon Yaari)
+- 1183_: Process.children() is 2x faster on UNIX and 2.4x faster on Linux.
+- 1188_: deprecated method Process.memory_info_ex() now warns by using
+  FutureWarning instead of DeprecationWarning.
+
+**Bug fixes**
+
+- 1152_: [Windows] disk_io_counters() may return an empty dict.
+- 1169_: [Linux] users() "hostname" returns username instead.  (patch by
+  janderbrain)
+- 1172_: [Windows] `make test` does not work.
+- 1179_: [Linux] Process.cmdline() is now able to splits cmdline args for
+  misbehaving processes which overwrite /proc/pid/cmdline and use spaces
+  instead of null bytes as args separator.
+- 1181_: [OSX] Process.memory_maps() may raise ENOENT.
+- 1187_: [OSX] pids() does not return PID 0 on recent OSX versions.
+
 5.4.1
 =====
 
diff --git a/INSTALL.rst b/INSTALL.rst
index 8737c94..f2a80ee 100644
--- a/INSTALL.rst
+++ b/INSTALL.rst
@@ -4,16 +4,22 @@ Install pip
 pip is the easiest way to install psutil.
 It is shipped by default with Python 2.7.9+ and 3.4+. For other Python versions
 you can install it manually.
-On Linux or via wget::
+On Linux or via wget:
+
+.. code-block:: bash
 
     wget https://bootstrap.pypa.io/get-pip.py -O - | python
 
-On OSX or via curl::
+On OSX or via curl:
+
+.. code-block:: bash
 
     python < <(curl -s https://bootstrap.pypa.io/get-pip.py)
 
 On Windows, `download pip <https://pip.pypa.io/en/latest/installing/>`__, open
-cmd.exe and install it::
+cmd.exe and install it:
+
+.. code-block:: bat
 
     C:\Python27\python.exe get-pip.py
 
@@ -25,50 +31,43 @@ If you're not or you bump into permission errors you can either:
 
 * prepend ``sudo``, e.g.:
 
-::
+.. code-block:: bash
 
     sudo pip install psutil
 
 * install psutil for your user only (not at system level):
 
-::
+.. code-block:: bash
 
     pip install --user psutil
 
 Linux
 =====
 
-Ubuntu / Debian::
+Ubuntu / Debian:
+
+.. code-block:: bash
 
     sudo apt-get install gcc python-dev python-pip
     pip install psutil
 
-RedHat / CentOS::
+RedHat / CentOS:
+
+
+.. code-block:: bash
 
     sudo yum install gcc python-devel python-pip
     pip install psutil
 
 If you're on Python 3 use ``python3-dev`` and ``python3-pip`` instead.
 
-Major Linux distros also provide binary distributions of psutil so, for
-instance, on Ubuntu and Debian you can also do::
-
-    sudo apt-get install python-psutil
-
-On RedHat and CentOS::
-
-    sudo yum install python-psutil
-
-This is not recommended though as Linux distros usually ship older psutil
-versions.
-
 OSX
 ===
 
 Install `Xcode <https://developer.apple.com/downloads/?name=Xcode>`__
 first, then:
 
-::
+.. code-block:: bash
 
     pip install psutil
 
@@ -77,7 +76,9 @@ Windows
 
 The easiest way to install psutil on Windows is to just use the pre-compiled
 exe/wheel installers hosted on
-`PYPI <https://pypi.python.org/pypi/psutil/#downloads>`__ via pip::
+`PYPI <https://pypi.python.org/pypi/psutil/#downloads>`__ via pip:
+
+.. code-block:: bat
 
     C:\Python27\python.exe -m pip install psutil
 
@@ -92,7 +93,9 @@ Compiling 64 bit versions of Python 2.6 and 2.7 with VS 2008 requires
 `Windows SDK and .NET Framework 3.5 SP1 <https://www.microsoft.com/en-us/download/details.aspx?id=3138>`__.
 Once installed run vcvars64.bat, then you can finally compile (see
 `here <http://stackoverflow.com/questions/11072521/>`__).
-To compile / install psutil from sources on Windows run::
+To compile / install psutil from sources on Windows run:
+
+.. code-block:: bat
 
     make.bat build
     make.bat install
@@ -100,7 +103,7 @@ To compile / install psutil from sources on Windows run::
 FreeBSD
 =======
 
-::
+.. code-block:: bash
 
     pkg install python gcc
     python -m pip install psutil
@@ -108,7 +111,7 @@ FreeBSD
 OpenBSD
 =======
 
-::
+.. code-block:: bash
 
     export PKG_PATH="http://ftp.openbsd.org/pub/OpenBSD/`uname -r`/packages/`arch -s`/"
     pkg_add -v python gcc
@@ -117,7 +120,7 @@ OpenBSD
 NetBSD
 ======
 
-::
+.. code-block:: bash
 
     export PKG_PATH="ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/`uname -m`/`uname -r`/All"
     pkg_add -v pkgin
@@ -129,13 +132,13 @@ Solaris
 
 If ``cc`` compiler is not installed create a symlink to ``gcc``:
 
-::
+.. code-block:: bash
 
     sudo ln -s /usr/bin/gcc /usr/local/bin/cc
 
 Install:
 
-::
+.. code-block:: bash
 
     pkg install gcc
     python -m pip install psutil
@@ -143,7 +146,7 @@ Install:
 Install from sources
 ====================
 
-::
+.. code-block:: bash
 
     git clone https://github.com/giampaolo/psutil.git
     cd psutil
diff --git a/MANIFEST.in b/MANIFEST.in
index 1194501..7a92a4e 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -24,6 +24,7 @@ include psutil/DEVNOTES
 include psutil/__init__.py
 include psutil/_common.py
 include psutil/_compat.py
+include psutil/_exceptions.py
 include psutil/_psaix.py
 include psutil/_psbsd.py
 include psutil/_pslinux.py
diff --git a/Makefile b/Makefile
index 035c72f..080e334 100644
--- a/Makefile
+++ b/Makefile
@@ -22,10 +22,11 @@ DEPS = \
 	sphinx \
 	twine \
 	unittest2 \
-	requests
+	wheel
 
 # In not in a virtualenv, add --user options for install commands.
 INSTALL_OPTS = `$(PYTHON) -c "import sys; print('' if hasattr(sys, 'real_prefix') else '--user')"`
+TEST_PREFIX = PYTHONWARNINGS=all PSUTIL_TESTING=1 PSUTIL_DEBUG=1
 
 all: test
 
@@ -108,53 +109,53 @@ setup-dev-env:  ## Install GIT hooks, pip, test deps (also upgrades them).
 
 test:  ## Run all tests.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) $(TSCRIPT)
+	$(TEST_PREFIX) $(PYTHON) $(TSCRIPT)
 
 test-process:  ## Run process-related API tests.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) -m unittest -v psutil.tests.test_process
+	$(TEST_PREFIX) $(PYTHON) -m unittest -v psutil.tests.test_process
 
 test-system:  ## Run system-related API tests.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) -m unittest -v psutil.tests.test_system
+	$(TEST_PREFIX) $(PYTHON) -m unittest -v psutil.tests.test_system
 
 test-misc:  ## Run miscellaneous tests.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_misc.py
+	$(TEST_PREFIX) $(PYTHON) psutil/tests/test_misc.py
 
 test-unicode:  ## Test APIs dealing with strings.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_unicode.py
+	$(TEST_PREFIX) $(PYTHON) psutil/tests/test_unicode.py
 
 test-contracts:  ## APIs sanity tests.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_contracts.py
+	$(TEST_PREFIX) $(PYTHON) psutil/tests/test_contracts.py
 
 test-connections:  ## Test net_connections() and Process.connections().
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_connections.py
+	$(TEST_PREFIX) $(PYTHON) psutil/tests/test_connections.py
 
 test-posix:  ## POSIX specific tests.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_posix.py
+	$(TEST_PREFIX) $(PYTHON) psutil/tests/test_posix.py
 
 test-platform:  ## Run specific platform tests only.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py
+	$(TEST_PREFIX) $(PYTHON) psutil/tests/test_`$(PYTHON) -c 'import psutil; print([x.lower() for x in ("LINUX", "BSD", "OSX", "SUNOS", "WINDOWS", "AIX") if getattr(psutil, x)][0])'`.py
 
 test-memleaks:  ## Memory leak tests.
 	${MAKE} install
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) psutil/tests/test_memory_leaks.py
+	$(TEST_PREFIX) $(PYTHON) psutil/tests/test_memory_leaks.py
 
 test-by-name:  ## e.g. make test-by-name ARGS=psutil.tests.test_system.TestSystemAPIs
 	${MAKE} install
-	@PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) -m unittest -v $(ARGS)
+	@$(TEST_PREFIX) $(PYTHON) -m unittest -v $(ARGS)
 
 test-coverage:  ## Run test coverage.
 	${MAKE} install
 	# Note: coverage options are controlled by .coveragerc file
 	rm -rf .coverage htmlcov
-	PSUTIL_TESTING=1 PYTHONWARNINGS=all $(PYTHON) -m coverage run $(TSCRIPT)
+	$(TEST_PREFIX) $(PYTHON) -m coverage run $(TSCRIPT)
 	$(PYTHON) -m coverage report
 	@echo "writing results to htmlcov/index.html"
 	$(PYTHON) -m coverage html
@@ -190,21 +191,31 @@ install-git-hooks:  ## Install GIT pre-commit hook.
 # Distribution
 # ===================================================================
 
-sdist:  ## Generate tar.gz source distribution.
+# --- create
+
+sdist:  ## Create tar.gz source distribution.
 	${MAKE} generate-manifest
 	$(PYTHON) setup.py sdist
 
+wheel:  ## Generate wheel.
+	$(PYTHON) setup.py bdist_wheel
+
+win-download-wheels:  ## Download wheels hosted on appveyor.
+	$(TEST_PREFIX) $(PYTHON) scripts/internal/download_exes.py --user giampaolo --project psutil
+
+# --- upload
+
 upload-src:  ## Upload source tarball on https://pypi.python.org/pypi/psutil.
 	${MAKE} sdist
 	$(PYTHON) setup.py sdist upload
 
-win-download-exes:  ## Download exes/wheels hosted on appveyor.
-	PYTHONWARNINGS=all $(PYTHON) scripts/internal/download_exes.py --user giampaolo --project psutil
-
-win-upload-exes:  ## Upload wheels in dist/* directory on PYPI.
+upload-win-wheels:  ## Upload wheels in dist/* directory on PYPI.
 	$(PYTHON) -m twine upload dist/*.whl
 
+# --- others
+
 pre-release:  ## Check if we're ready to produce a new release.
+	rm -rf dist
 	${MAKE} install
 	$(PYTHON) -c \
 		"from psutil import __version__ as ver; \
@@ -216,7 +227,7 @@ pre-release:  ## Check if we're ready to produce a new release.
 	${MAKE} generate-manifest
 	git diff MANIFEST.in > /dev/null  # ...otherwise 'git diff-index HEAD' will complain
 	$(PYTHON) -c "import subprocess, sys; out = subprocess.check_output('git diff-index HEAD --', shell=True).strip(); sys.exit('there are uncommitted changes:\n%s' % out) if out else sys.exit(0);"
-	${MAKE} win-download-exes
+	${MAKE} win-download-wheels
 	${MAKE} sdist
 
 release:  ## Create a release (down/uploads tar.gz, wheels, git tag release).
@@ -225,10 +236,10 @@ release:  ## Create a release (down/uploads tar.gz, wheels, git tag release).
 	${MAKE} git-tag-release
 
 print-announce:  ## Print announce of new release.
-	@PYTHONWARNINGS=all $(PYTHON) scripts/internal/print_announce.py
+	@$(TEST_PREFIX) $(PYTHON) scripts/internal/print_announce.py
 
 print-timeline:  ## Print releases' timeline.
-	@PYTHONWARNINGS=all $(PYTHON) scripts/internal/print_timeline.py
+	@$(TEST_PREFIX) $(PYTHON) scripts/internal/print_timeline.py
 
 check-manifest:  ## Inspect MANIFEST.in file.
 	$(PYTHON) -m check_manifest -v $(ARGS)
@@ -245,11 +256,11 @@ grep-todos:  ## Look for TODOs in the source files.
 
 bench-oneshot:  ## Benchmarks for oneshot() ctx manager (see #799).
 	${MAKE} install
-	PYTHONWARNINGS=all $(PYTHON) scripts/internal/bench_oneshot.py
+	$(TEST_PREFIX) $(PYTHON) scripts/internal/bench_oneshot.py
 
 bench-oneshot-2:  ## Same as above but using perf module (supposed to be more precise)
 	${MAKE} install
-	PYTHONWARNINGS=all $(PYTHON) scripts/internal/bench_oneshot_2.py
+	$(TEST_PREFIX) $(PYTHON) scripts/internal/bench_oneshot_2.py
 
 check-broken-links:  ## Look for broken links in source files.
 		git ls-files | xargs $(PYTHON) -Wa scripts/internal/check_broken_links.py
diff --git a/PKG-INFO b/PKG-INFO
index a97e699..a4c01ed 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: psutil
-Version: 5.4.1
+Version: 5.4.2
 Summary: Cross-platform lib for process and system monitoring in Python.
 Home-page: https://github.com/giampaolo/psutil
 Author: Giampaolo Rodola
@@ -70,8 +70,7 @@ Description: .. image:: https://img.shields.io/travis/giampaolo/psutil/master.sv
         - **AIX**
         
         ...both **32-bit** and **64-bit** architectures, with Python
-        versions from **2.6 to 3.6** (users of Python 2.4 and 2.5 may use
-        `2.1.3 <https://pypi.python.org/pypi?name=psutil&version=2.1.3&:action=files>`__ version).
+        versions from **2.6 to 3.6**.
         `PyPy <http://pypy.org/>`__ is also known to work.
         
         ====================
diff --git a/README.rst b/README.rst
index 4559e55..4ac707a 100644
--- a/README.rst
+++ b/README.rst
@@ -61,8 +61,7 @@ psutil currently supports the following platforms:
 - **AIX**
 
 ...both **32-bit** and **64-bit** architectures, with Python
-versions from **2.6 to 3.6** (users of Python 2.4 and 2.5 may use
-`2.1.3 <https://pypi.python.org/pypi?name=psutil&version=2.1.3&:action=files>`__ version).
+versions from **2.6 to 3.6**.
 `PyPy <http://pypy.org/>`__ is also known to work.
 
 ====================
diff --git a/docs/index.rst b/docs/index.rst
index 7690dfe..c09045f 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -766,6 +766,8 @@ Sensors
 
   .. versionadded:: 5.1.0
 
+  .. versionchanged:: 5.4.2 added OSX support
+
   .. warning::
 
     this API is experimental. Backward incompatible changes may occur if
@@ -1714,9 +1716,9 @@ Process class
 
   .. method:: children(recursive=False)
 
-    Return the children of this process as a list of :Class:`Process` objects,
-    preemptively checking whether PID has been reused. If recursive is `True`
-    return all the parent descendants.
+    Return the children of this process as a list of :class:`Process`
+    instances.
+    If recursive is `True` return all the parent descendants.
     Pseudo code example assuming *A == this process*:
     ::
 
@@ -1736,7 +1738,7 @@ Process class
     Note that in the example above if process X disappears process Y won't be
     returned either as the reference to process A is lost.
     This concept is well summaried by this
-    `unit test <https://github.com/giampaolo/psutil/blob/fb9ae861cf3cf175c3da4a3cd4e558c6cbd6af91/psutil/tests/test_process.py#L1236-L1247>`__.
+    `unit test <https://github.com/giampaolo/psutil/blob/65a52341b55faaab41f68ebc4ed31f18f0929754/psutil/tests/test_process.py#L1064-L1075>`__.
     See also how to `kill a process tree <#kill-process-tree>`__ and
     `terminate my children <#terminate-my-children>`__.
 
@@ -2520,8 +2522,8 @@ Top 3 processes opening more file descriptors::
    (2721, {'name': 'chrome', 'num_fds': 185}),
    (2650, {'name': 'chrome', 'num_fds': 354})]
 
-Q&A
-===
+FAQs
+====
 
 * Q: What Windows versions are supported?
 * A: From Windows **Vista** onwards, both 32 and 64 bit versions.
@@ -2534,6 +2536,13 @@ Q&A
 
 ----
 
+* Q: What Python versions are supported?
+* A: From 2.6 to 3.6, both 32 and 64 bit versions. Last version supporting
+  Python 2.4 and 2.5 is `psutil 2.1.3 <https://pypi.python.org/pypi?name=psutil&version=2.1.3&:action=files>`__.
+  PyPy is also known to work.
+
+----
+
 * Q: What SunOS versions are supported?
 * A: From Solaris 10 onwards.
 
@@ -2580,6 +2589,10 @@ take a look at the
 Timeline
 ========
 
+- 2017-12-07:
+  `5.4.1 <https://pypi.python.org/pypi?name=psutil&version=5.4.2&:action=files>`__ -
+  `what's new <https://github.com/giampaolo/psutil/blob/master/HISTORY.rst#542>`__ -
+  `diff <https://github.com/giampaolo/psutil/compare/release-5.4.1...release-5.4.2#files_bucket>`__
 - 2017-11-08:
   `5.4.1 <https://pypi.python.org/pypi?name=psutil&version=5.4.1&:action=files>`__ -
   `what's new <https://github.com/giampaolo/psutil/blob/master/HISTORY.rst#541>`__ -
diff --git a/psutil.egg-info/PKG-INFO b/psutil.egg-info/PKG-INFO
index a97e699..a4c01ed 100644
--- a/psutil.egg-info/PKG-INFO
+++ b/psutil.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: psutil
-Version: 5.4.1
+Version: 5.4.2
 Summary: Cross-platform lib for process and system monitoring in Python.
 Home-page: https://github.com/giampaolo/psutil
 Author: Giampaolo Rodola
@@ -70,8 +70,7 @@ Description: .. image:: https://img.shields.io/travis/giampaolo/psutil/master.sv
         - **AIX**
         
         ...both **32-bit** and **64-bit** architectures, with Python
-        versions from **2.6 to 3.6** (users of Python 2.4 and 2.5 may use
-        `2.1.3 <https://pypi.python.org/pypi?name=psutil&version=2.1.3&:action=files>`__ version).
+        versions from **2.6 to 3.6**.
         `PyPy <http://pypy.org/>`__ is also known to work.
         
         ====================
diff --git a/psutil.egg-info/SOURCES.txt b/psutil.egg-info/SOURCES.txt
index edd6262..b0482a7 100644
--- a/psutil.egg-info/SOURCES.txt
+++ b/psutil.egg-info/SOURCES.txt
@@ -26,6 +26,7 @@ psutil/DEVNOTES
 psutil/__init__.py
 psutil/_common.py
 psutil/_compat.py
+psutil/_exceptions.py
 psutil/_psaix.py
 psutil/_psbsd.py
 psutil/_pslinux.py
diff --git a/psutil/__init__.py b/psutil/__init__.py
index 01934ac..7a17093 100644
--- a/psutil/__init__.py
+++ b/psutil/__init__.py
@@ -24,6 +24,7 @@ from __future__ import division
 
 import collections
 import contextlib
+import datetime
 import errno
 import functools
 import os
@@ -85,6 +86,12 @@ from ._common import POSIX  # NOQA
 from ._common import SUNOS
 from ._common import WINDOWS
 
+from ._exceptions import AccessDenied
+from ._exceptions import Error
+from ._exceptions import NoSuchProcess
+from ._exceptions import TimeoutExpired
+from ._exceptions import ZombieProcess
+
 if LINUX:
     # This is public API and it will be retrieved from _pslinux.py
     # via sys.modules.
@@ -212,7 +219,7 @@ __all__ = [
 ]
 __all__.extend(_psplatform.__extra__all__)
 __author__ = "Giampaolo Rodola'"
-__version__ = "5.4.1"
+__version__ = "5.4.2"
 version_info = tuple([int(num) for num in __version__.split('.')])
 AF_LINK = _psplatform.AF_LINK
 POWER_TIME_UNLIMITED = _common.POWER_TIME_UNLIMITED
@@ -244,112 +251,29 @@ if (int(__version__.replace('.', '')) !=
 
 
 # =====================================================================
-# --- exceptions
+# --- Utils
 # =====================================================================
 
 
-class Error(Exception):
-    """Base exception class. All other psutil exceptions inherit
-    from this one.
-    """
-
-    def __init__(self, msg=""):
-        Exception.__init__(self, msg)
-        self.msg = msg
-
-    def __repr__(self):
-        ret = "%s.%s %s" % (self.__class__.__module__,
-                            self.__class__.__name__, self.msg)
-        return ret.strip()
-
-    __str__ = __repr__
-
-
-class NoSuchProcess(Error):
-    """Exception raised when a process with a certain PID doesn't
-    or no longer exists.
-    """
-
-    def __init__(self, pid, name=None, msg=None):
-        Error.__init__(self, msg)
-        self.pid = pid
-        self.name = name
-        self.msg = msg
-        if msg is None:
-            if name:
-                details = "(pid=%s, name=%s)" % (self.pid, repr(self.name))
-            else:
-                details = "(pid=%s)" % self.pid
-            self.msg = "process no longer exists " + details
-
-
-class ZombieProcess(NoSuchProcess):
-    """Exception raised when querying a zombie process. This is
-    raised on OSX, BSD and Solaris only, and not always: depending
-    on the query the OS may be able to succeed anyway.
-    On Linux all zombie processes are querable (hence this is never
-    raised). Windows doesn't have zombie processes.
-    """
-
-    def __init__(self, pid, name=None, ppid=None, msg=None):
-        NoSuchProcess.__init__(self, msg)
-        self.pid = pid
-        self.ppid = ppid
-        self.name = name
-        self.msg = msg
-        if msg is None:
-            args = ["pid=%s" % pid]
-            if name:
-                args.append("name=%s" % repr(self.name))
-            if ppid:
-                args.append("ppid=%s" % self.ppid)
-            details = "(%s)" % ", ".join(args)
-            self.msg = "process still exists but it's a zombie " + details
-
-
-class AccessDenied(Error):
-    """Exception raised when permission to perform an action is denied."""
-
-    def __init__(self, pid=None, name=None, msg=None):
-        Error.__init__(self, msg)
-        self.pid = pid
-        self.name = name
-        self.msg = msg
-        if msg is None:
-            if (pid is not None) and (name is not None):
-                self.msg = "(pid=%s, name=%s)" % (pid, repr(name))
-            elif (pid is not None):
-                self.msg = "(pid=%s)" % self.pid
+if hasattr(_psplatform, 'ppid_map'):
+    # Faster version (Windows and Linux).
+    _ppid_map = _psplatform.ppid_map
+else:
+    def _ppid_map():
+        """Return a {pid: ppid, ...} dict for all running processes in
+        one shot. Used to speed up Process.children().
+        """
+        ret = {}
+        for pid in pids():
+            try:
+                proc = _psplatform.Process(pid)
+                ppid = proc.ppid()
+            except (NoSuchProcess, AccessDenied):
+                # Note: AccessDenied is unlikely to happen.
+                pass
             else:
-                self.msg = ""
-
-
-class TimeoutExpired(Error):
-    """Raised on Process.wait(timeout) if timeout expires and process
-    is still alive.
-    """
-
-    def __init__(self, seconds, pid=None, name=None):
-        Error.__init__(self, "timeout after %s seconds" % seconds)
-        self.seconds = seconds
-        self.pid = pid
-        self.name = name
-        if (pid is not None) and (name is not None):
-            self.msg += " (pid=%s, name=%s)" % (pid, repr(name))
-        elif (pid is not None):
-            self.msg += " (pid=%s)" % self.pid
-
-
-# push exception classes into platform specific module namespace
-_psplatform.NoSuchProcess = NoSuchProcess
-_psplatform.ZombieProcess = ZombieProcess
-_psplatform.AccessDenied = AccessDenied
-_psplatform.TimeoutExpired = TimeoutExpired
-
-
-# =====================================================================
-# --- Process class
-# =====================================================================
+                ret[pid] = ppid
+        return ret
 
 
 def _assert_pid_not_reused(fun):
@@ -364,6 +288,22 @@ def _assert_pid_not_reused(fun):
     return wrapper
 
 
+def _pprint_secs(secs):
+    """Format seconds in a human readable form."""
+    now = time.time()
+    secs_ago = int(now - secs)
+    if secs_ago < 60 * 60 * 24:
+        fmt = "%H:%M:%S"
+    else:
+        fmt = "%Y-%m-%d %H:%M:%S"
+    return datetime.datetime.fromtimestamp(secs).strftime(fmt)
+
+
+# =====================================================================
+# --- Process class
+# =====================================================================
+
+
 class Process(object):
     """Represents an OS process with the given PID.
     If PID is omitted current process PID (os.getpid()) is used.
@@ -449,21 +389,26 @@ class Process(object):
 
     def __str__(self):
         try:
-            pid = self.pid
-            name = repr(self.name())
+            info = collections.OrderedDict()
+        except AttributeError:
+            info = {}  # Python 2.6
+        info["pid"] = self.pid
+        try:
+            info["name"] = self.name()
+            if self._create_time:
+                info['started'] = _pprint_secs(self._create_time)
         except ZombieProcess:
-            details = "(pid=%s (zombie))" % self.pid
+            info["status"] = "zombie"
         except NoSuchProcess:
-            details = "(pid=%s (terminated))" % self.pid
+            info["status"] = "terminated"
         except AccessDenied:
-            details = "(pid=%s)" % (self.pid)
-        else:
-            details = "(pid=%s, name=%s)" % (pid, name)
-        return "%s.%s%s" % (self.__class__.__module__,
-                            self.__class__.__name__, details)
+            pass
+        return "%s.%s(%s)" % (
+            self.__class__.__module__,
+            self.__class__.__name__,
+            ", ".join(["%s=%r" % (k, v) for k, v in info.items()]))
 
-    def __repr__(self):
-        return "<%s at %s>" % (self.__str__(), id(self))
+    __repr__ = __str__
 
     def __eq__(self, other):
         # Test for equality with another Process object based
@@ -946,73 +891,47 @@ class Process(object):
         process Y won't be listed as the reference to process A
         is lost.
         """
-        if hasattr(_psplatform, 'ppid_map'):
-            # Windows only: obtain a {pid:ppid, ...} dict for all running
-            # processes in one shot (faster).
-            ppid_map = _psplatform.ppid_map()
-        else:
-            ppid_map = None
-
+        ppid_map = _ppid_map()
         ret = []
         if not recursive:
-            if ppid_map is None:
-                # 'slow' version, common to all platforms except Windows
-                for p in process_iter():
+            for pid, ppid in ppid_map.items():
+                if ppid == self.pid:
                     try:
-                        if p.ppid() == self.pid:
-                            # if child happens to be older than its parent
-                            # (self) it means child's PID has been reused
-                            if self.create_time() <= p.create_time():
-                                ret.append(p)
+                        child = Process(pid)
+                        # if child happens to be older than its parent
+                        # (self) it means child's PID has been reused
+                        if self.create_time() <= child.create_time():
+                            ret.append(child)
                     except (NoSuchProcess, ZombieProcess):
                         pass
-            else:  # pragma: no cover
-                # Windows only (faster)
-                for pid, ppid in ppid_map.items():
-                    if ppid == self.pid:
-                        try:
-                            child = Process(pid)
-                            # if child happens to be older than its parent
-                            # (self) it means child's PID has been reused
-                            if self.create_time() <= child.create_time():
-                                ret.append(child)
-                        except (NoSuchProcess, ZombieProcess):
-                            pass
         else:
-            # construct a dict where 'values' are all the processes
-            # having 'key' as their parent
-            table = collections.defaultdict(list)
-            if ppid_map is None:
-                for p in process_iter():
-                    try:
-                        table[p.ppid()].append(p)
-                    except (NoSuchProcess, ZombieProcess):
-                        pass
-            else:  # pragma: no cover
-                for pid, ppid in ppid_map.items():
-                    try:
-                        p = Process(pid)
-                        table[ppid].append(p)
-                    except (NoSuchProcess, ZombieProcess):
-                        pass
-            # At this point we have a mapping table where table[self.pid]
-            # are the current process' children.
-            # Below, we look for all descendants recursively, similarly
-            # to a recursive function call.
-            checkpids = [self.pid]
-            for pid in checkpids:
-                for child in table[pid]:
+            # Construct a {pid: [child pids]} dict
+            reverse_ppid_map = collections.defaultdict(list)
+            for pid, ppid in ppid_map.items():
+                reverse_ppid_map[ppid].append(pid)
+            # Recursively traverse that dict, starting from self.pid,
+            # such that we only call Process() on actual children
+            seen = set()
... 2339 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