[Python-modules-commits] [python-psutil] 01/07: Import python-psutil_3.4.2.orig.tar.gz
Sandro Tosi
morph at moszumanska.debian.org
Mon Feb 8 22:27:05 UTC 2016
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository python-psutil.
commit 120c55e707cbc9152171f0d82890d996e7484598
Author: Sandro Tosi <morph at debian.org>
Date: Mon Feb 8 22:17:36 2016 +0000
Import python-psutil_3.4.2.orig.tar.gz
---
.ci/README | 3 ++
.ci/appveyor/README | 2 +
.ci/appveyor/install.ps1 | 85 ++++++++++++++++++++++++++++++++++++++
.ci/appveyor/run_with_compiler.cmd | 47 +++++++++++++++++++++
.ci/travis/README | 2 +
.ci/travis/install.sh | 51 +++++++++++++++++++++++
.ci/travis/run.sh | 18 ++++++++
CREDITS | 4 ++
HISTORY.rst | 23 +++++++----
MANIFEST.in | 2 +-
PKG-INFO | 6 ++-
README.rst | 1 +
docs/index.rst | 63 ++++++++++++++--------------
psutil.egg-info/PKG-INFO | 6 ++-
psutil.egg-info/SOURCES.txt | 7 ++++
psutil/__init__.py | 8 +++-
psutil/_pssunos.py | 83 +++++++++++++++++++++++--------------
psutil/_psutil_sunos.c | 59 +++++++++++++++-----------
psutil/arch/bsd/freebsd.c | 3 +-
setup.py | 3 ++
20 files changed, 376 insertions(+), 100 deletions(-)
diff --git a/.ci/README b/.ci/README
new file mode 100644
index 0000000..86b72af
--- /dev/null
+++ b/.ci/README
@@ -0,0 +1,3 @@
+This directory contains support scripts for Travis and Appveyor continuous
+integration services.
+Travis is used to run tests on Linux and OSX, Appveyor runs tests on Windows.
diff --git a/.ci/appveyor/README b/.ci/appveyor/README
new file mode 100644
index 0000000..2e092a0
--- /dev/null
+++ b/.ci/appveyor/README
@@ -0,0 +1,2 @@
+This directory contains support files for appveyor, a continuous integration
+service which runs tests on Windows on every push.
diff --git a/.ci/appveyor/install.ps1 b/.ci/appveyor/install.ps1
new file mode 100644
index 0000000..3f05628
--- /dev/null
+++ b/.ci/appveyor/install.ps1
@@ -0,0 +1,85 @@
+# Sample script to install Python and pip under Windows
+# Authors: Olivier Grisel and Kyle Kastner
+# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
+
+$BASE_URL = "https://www.python.org/ftp/python/"
+$GET_PIP_URL = "https://bootstrap.pypa.io/get-pip.py"
+$GET_PIP_PATH = "C:\get-pip.py"
+
+
+function DownloadPython ($python_version, $platform_suffix) {
+ $webclient = New-Object System.Net.WebClient
+ $filename = "python-" + $python_version + $platform_suffix + ".msi"
+ $url = $BASE_URL + $python_version + "/" + $filename
+
+ $basedir = $pwd.Path + "\"
+ $filepath = $basedir + $filename
+ if (Test-Path $filename) {
+ Write-Host "Reusing" $filepath
+ return $filepath
+ }
+
+ # Download and retry up to 5 times in case of network transient errors.
+ Write-Host "Downloading" $filename "from" $url
+ $retry_attempts = 3
+ for($i=0; $i -lt $retry_attempts; $i++){
+ try {
+ $webclient.DownloadFile($url, $filepath)
+ break
+ }
+ Catch [Exception]{
+ Start-Sleep 1
+ }
+ }
+ Write-Host "File saved at" $filepath
+ return $filepath
+}
+
+
+function InstallPython ($python_version, $architecture, $python_home) {
+ Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
+ if (Test-Path $python_home) {
+ Write-Host $python_home "already exists, skipping."
+ return $false
+ }
+ if ($architecture -eq "32") {
+ $platform_suffix = ""
+ } else {
+ $platform_suffix = ".amd64"
+ }
+ $filepath = DownloadPython $python_version $platform_suffix
+ Write-Host "Installing" $filepath "to" $python_home
+ $args = "/qn /i $filepath TARGETDIR=$python_home"
+ Write-Host "msiexec.exe" $args
+ Start-Process -FilePath "msiexec.exe" -ArgumentList $args -Wait -Passthru
+ Write-Host "Python $python_version ($architecture) installation complete"
+ return $true
+}
+
+
+function InstallPip ($python_home) {
+ $pip_path = $python_home + "/Scripts/pip.exe"
+ $python_path = $python_home + "/python.exe"
+ if (-not(Test-Path $pip_path)) {
+ Write-Host "Installing pip..."
+ $webclient = New-Object System.Net.WebClient
+ $webclient.DownloadFile($GET_PIP_URL, $GET_PIP_PATH)
+ Write-Host "Executing:" $python_path $GET_PIP_PATH
+ Start-Process -FilePath "$python_path" -ArgumentList "$GET_PIP_PATH" -Wait -Passthru
+ } else {
+ Write-Host "pip already installed."
+ }
+}
+
+function InstallPackage ($python_home, $pkg) {
+ $pip_path = $python_home + "/Scripts/pip.exe"
+ & $pip_path install $pkg
+}
+
+function main () {
+ InstallPython $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON
+ InstallPip $env:PYTHON
+ InstallPackage $env:PYTHON wheel
+}
+
+main
diff --git a/.ci/appveyor/run_with_compiler.cmd b/.ci/appveyor/run_with_compiler.cmd
new file mode 100644
index 0000000..3a472bc
--- /dev/null
+++ b/.ci/appveyor/run_with_compiler.cmd
@@ -0,0 +1,47 @@
+:: To build extensions for 64 bit Python 3, we need to configure environment
+:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
+:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
+::
+:: To build extensions for 64 bit Python 2, we need to configure environment
+:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
+:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
+::
+:: 32 bit builds do not require specific environment configurations.
+::
+:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
+:: cmd interpreter, at least for (SDK v7.0)
+::
+:: More details at:
+:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
+:: http://stackoverflow.com/a/13751649/163740
+::
+:: Author: Olivier Grisel
+:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
+ at ECHO OFF
+
+SET COMMAND_TO_RUN=%*
+SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
+
+SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
+IF %MAJOR_PYTHON_VERSION% == "2" (
+ SET WINDOWS_SDK_VERSION="v7.0"
+) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
+ SET WINDOWS_SDK_VERSION="v7.1"
+) ELSE (
+ ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
+ EXIT 1
+)
+
+IF "%PYTHON_ARCH%"=="64" (
+ ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
+ SET DISTUTILS_USE_SDK=1
+ SET MSSdk=1
+ "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
+ "%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
+ ECHO Executing: %COMMAND_TO_RUN%
+ call %COMMAND_TO_RUN% || EXIT 1
+) ELSE (
+ ECHO Using default MSVC build environment for 32 bit architecture
+ ECHO Executing: %COMMAND_TO_RUN%
+ call %COMMAND_TO_RUN% || EXIT 1
+)
diff --git a/.ci/travis/README b/.ci/travis/README
new file mode 100644
index 0000000..d9d5f65
--- /dev/null
+++ b/.ci/travis/README
@@ -0,0 +1,2 @@
+This directory contains support files for Travis, a continuous integration
+service which runs tests on Linux and Windows on every push.
diff --git a/.ci/travis/install.sh b/.ci/travis/install.sh
new file mode 100755
index 0000000..23d9ce0
--- /dev/null
+++ b/.ci/travis/install.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+set -e
+set -x
+
+if [[ "$(uname -s)" == 'Darwin' ]]; then
+ brew update || brew update
+ brew outdated pyenv || brew upgrade pyenv
+ brew install pyenv-virtualenv
+
+ if which pyenv > /dev/null; then
+ eval "$(pyenv init -)"
+ fi
+
+ case "${PYVER}" in
+ py26)
+ pyenv install 2.6.9
+ pyenv virtualenv 2.6.9 psutil
+ ;;
+ py27)
+ pyenv install 2.7.10
+ pyenv virtualenv 2.7.10 psutil
+ ;;
+ py32)
+ pyenv install 3.2.6
+ pyenv virtualenv 3.2.6 psutil
+ ;;
+ py33)
+ pyenv install 3.3.6
+ pyenv virtualenv 3.3.6 psutil
+ ;;
+ py34)
+ pyenv install 3.4.3
+ pyenv virtualenv 3.4.3 psutil
+ ;;
+ esac
+ pyenv rehash
+ pyenv activate psutil
+fi
+
+if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]] || [[ $PYVER == 'py26' ]]; then
+ pip install -U ipaddress unittest2 mock==1.0.1
+elif [[ $TRAVIS_PYTHON_VERSION == '2.7' ]] || [[ $PYVER == 'py27' ]]; then
+ pip install -U ipaddress mock
+elif [[ $TRAVIS_PYTHON_VERSION == '3.2' ]] || [[ $PYVER == 'py32' ]]; then
+ pip install -U ipaddress mock
+elif [[ $TRAVIS_PYTHON_VERSION == '3.3' ]] || [[ $PYVER == 'py33' ]]; then
+ pip install -U ipaddress
+fi
+
+pip install coverage coveralls flake8 pep8
\ No newline at end of file
diff --git a/.ci/travis/run.sh b/.ci/travis/run.sh
new file mode 100755
index 0000000..41167aa
--- /dev/null
+++ b/.ci/travis/run.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -e
+set -x
+
+if [[ "$(uname -s)" == 'Darwin' ]]; then
+ if which pyenv > /dev/null; then
+ eval "$(pyenv init -)"
+ fi
+ pyenv activate psutil
+fi
+
+python setup.py build
+python setup.py install
+coverage run test/test_psutil.py --include="psutil/*" --omit="test/*,*setup*"
+python test/test_memory_leaks.py
+flake8
+pep8
diff --git a/CREDITS b/CREDITS
index ceb74d5..c5e5be9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -350,3 +350,7 @@ I: 541
N: Mike Sarahan
W: https://github.com/msarahan
I: 688
+
+N: Syohei YOSHIDA
+W: https://github.com/syohex
+I: 730
diff --git a/HISTORY.rst b/HISTORY.rst
index 108d413..d715fb0 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,5 +1,19 @@
Bug tracker at https://github.com/giampaolo/psutil/issues
+
+3.4.2 - 2016-01-20
+==================
+
+**Enhancements**
+
+- #728: [Solaris] exposed psutil.PROCFS_PATH constant to change the default
+ location of /proc filesystem.
+
+**Bug fixes**
+
+- #730: [FreeBSD] psutil.virtual_memory() crashes.
+
+
3.4.1 - 2016-01-15
==================
@@ -1108,11 +1122,4 @@ DeprecationWarning.
- #23: Special case for pid_exists(0)
- #24: [Windows] Process(0).kill() now raises AccessDenied exception instead
of WindowsError.
-- #30: psutil.get_pid_list() was returning two instances of PID 0 on OSX and
- FreeBSD platforms.
-
-
-0.1.0 - 2009-01-27
-==================
-
-- Initial release.
+- #30: psutil.get_pid_list() was returning two ins
diff --git a/MANIFEST.in b/MANIFEST.in
index 3e1db32..bddf43d 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -16,7 +16,7 @@ include setup.py
include TODO
include tox.ini
recursive-exclude docs/_build *
-recursive-include .ci/ *
+recursive-include .ci *
recursive-include docs *
recursive-include examples *.py
recursive-include psutil *.py *.c *.h
diff --git a/PKG-INFO b/PKG-INFO
index e86021f..422f7c0 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: psutil
-Version: 3.4.1
+Version: 3.4.2
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
@@ -355,6 +355,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
Timeline
========
+ - 2016-01-20: `psutil-3.4.2.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.2.tar.gz>`_
- 2016-01-15: `psutil-3.4.1.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.1.tar.gz>`_
- 2015-11-25: `psutil-3.3.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.3.0.tar.gz>`_
- 2015-10-04: `psutil-3.2.2.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.2.2.tar.gz>`_
@@ -409,7 +410,9 @@ Classifier: Operating System :: Microsoft :: Windows :: Windows NT/2000
Classifier: Operating System :: Microsoft
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX :: BSD :: FreeBSD
+Classifier: Operating System :: POSIX :: BSD :: NetBSD
Classifier: Operating System :: POSIX :: BSD :: OpenBSD
+Classifier: Operating System :: POSIX :: BSD
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: POSIX :: SunOS/Solaris
Classifier: Operating System :: POSIX
@@ -433,5 +436,6 @@ Classifier: Topic :: System :: Hardware
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Networking :: Monitoring
Classifier: Topic :: System :: Networking
+Classifier: Topic :: System :: Operating System
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
diff --git a/README.rst b/README.rst
index 6244edb..3e363a9 100644
--- a/README.rst
+++ b/README.rst
@@ -347,6 +347,7 @@ http://groups.google.com/group/psutil/
Timeline
========
+- 2016-01-20: `psutil-3.4.2.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.2.tar.gz>`_
- 2016-01-15: `psutil-3.4.1.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.1.tar.gz>`_
- 2015-11-25: `psutil-3.3.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.3.0.tar.gz>`_
- 2015-10-04: `psutil-3.2.2.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.2.2.tar.gz>`_
diff --git a/docs/index.rst b/docs/index.rst
index e4ef794..8b900b7 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -8,7 +8,7 @@
Old 1.2.1 documentation is still available
`here <https://code.google.com/p/psutil/wiki/Documentation>`__.
.. versionchanged:: 3.3.0 added support for OpenBSD
-.. versionchanged:: 3.4.0 added support for NetBSD
+.. versionchanged:: 3.4.1 added support for NetBSD
psutil documentation
====================
@@ -39,7 +39,7 @@ From project's home page:
such as: *ps, top, lsof, netstat, ifconfig, who, df, kill, free, nice,
ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap*.
It currently supports **Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD**
- and NetBSD, both **32-bit** and **64-bit** architectures, with Python
+ and **NetBSD**, both **32-bit** and **64-bit** architectures, with Python
versions from **2.6 to 3.5** (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).
`PyPy <http://pypy.org/>`__ is also known to work.
@@ -980,29 +980,29 @@ Process class
representing extended memory information about the process.
All numbers are expressed in bytes.
- +--------+---------+-------+-------+--------------------+
- | Linux | OSX | BSD | SunOS | Windows |
- +========+=========+=======+=======+====================+
- | rss | rss | rss | rss | num_page_faults |
- +--------+---------+-------+-------+--------------------+
- | vms | vms | vms | vms | peak_wset |
- +--------+---------+-------+-------+--------------------+
- | shared | pfaults | text | | wset |
- +--------+---------+-------+-------+--------------------+
- | text | pageins | data | | peak_paged_pool |
- +--------+---------+-------+-------+--------------------+
- | lib | | stack | | paged_pool |
- +--------+---------+-------+-------+--------------------+
- | data | | | | peak_nonpaged_pool |
- +--------+---------+-------+-------+--------------------+
- | dirty | | | | nonpaged_pool |
- +--------+---------+-------+-------+--------------------+
- | | | | | pagefile |
- +--------+---------+-------+-------+--------------------+
- | | | | | peak_pagefile |
- +--------+---------+-------+-------+--------------------+
- | | | | | private |
- +--------+---------+-------+-------+--------------------+
+ +--------+---------+-------+---------+--------------------+
+ | Linux | OSX | BSD | Solaris | Windows |
+ +========+=========+=======+=========+====================+
+ | rss | rss | rss | rss | num_page_faults |
+ +--------+---------+-------+---------+--------------------+
+ | vms | vms | vms | vms | peak_wset |
+ +--------+---------+-------+---------+--------------------+
+ | shared | pfaults | text | | wset |
+ +--------+---------+-------+---------+--------------------+
+ | text | pageins | data | | peak_paged_pool |
+ +--------+---------+-------+---------+--------------------+
+ | lib | | stack | | paged_pool |
+ +--------+---------+-------+---------+--------------------+
+ | data | | | | peak_nonpaged_pool |
+ +--------+---------+-------+---------+--------------------+
+ | dirty | | | | nonpaged_pool |
+ +--------+---------+-------+---------+--------------------+
+ | | | | | pagefile |
+ +--------+---------+-------+---------+--------------------+
+ | | | | | peak_pagefile |
+ +--------+---------+-------+---------+--------------------+
+ | | | | | private |
+ +--------+---------+-------+---------+--------------------+
Windows metrics are extracted from
`PROCESS_MEMORY_COUNTERS_EX <http://msdn.microsoft.com/en-us/library/windows/desktop/ms684874(v=vs.85).aspx>`__ structure.
@@ -1095,7 +1095,8 @@ Process class
.. warning::
on BSD this method can return files with a 'null' path due to a kernel
- bug (see `issue 595 <https://github.com/giampaolo/psutil/pull/595>`_).
+ bug hence it's not reliable
+ (see `issue 595 <https://github.com/giampaolo/psutil/pull/595>`_).
.. versionchanged:: 3.1.0 no longer hangs on Windows.
@@ -1286,12 +1287,14 @@ Constants
.. _const-pstatus:
.. data:: PROCFS_PATH
- The path of the /proc filesystem on Linux (defaults to "/proc"). You may want
- to re-set this in case /proc is mounted elsewhere.
+ The path of the /proc filesystem on Linux and Solaris (defaults to "/proc").
+ You may want to re-set this constant right after importing psutil in case
+ your /proc filesystem is mounted elsewhere.
- Availability: Linux
+ Availability: Linux, Solaris
.. versionadded:: 3.2.3
+ .. versionchanged:: 3.4.2 also available on Solaris.
.. _const-pstatus:
.. data:: STATUS_RUNNING
@@ -1311,7 +1314,7 @@ Constants
A set of strings representing the status of a process.
Returned by :meth:`psutil.Process.status()`.
- .. versionadded:: 3.4.0: STATUS_SUSPENDED (NetBSD)
+ .. versionadded:: 3.4.1 STATUS_SUSPENDED (NetBSD)
.. _const-conn:
.. data:: CONN_ESTABLISHED
diff --git a/psutil.egg-info/PKG-INFO b/psutil.egg-info/PKG-INFO
index e86021f..422f7c0 100644
--- a/psutil.egg-info/PKG-INFO
+++ b/psutil.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: psutil
-Version: 3.4.1
+Version: 3.4.2
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
@@ -355,6 +355,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
Timeline
========
+ - 2016-01-20: `psutil-3.4.2.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.2.tar.gz>`_
- 2016-01-15: `psutil-3.4.1.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.1.tar.gz>`_
- 2015-11-25: `psutil-3.3.0.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.3.0.tar.gz>`_
- 2015-10-04: `psutil-3.2.2.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.2.2.tar.gz>`_
@@ -409,7 +410,9 @@ Classifier: Operating System :: Microsoft :: Windows :: Windows NT/2000
Classifier: Operating System :: Microsoft
Classifier: Operating System :: OS Independent
Classifier: Operating System :: POSIX :: BSD :: FreeBSD
+Classifier: Operating System :: POSIX :: BSD :: NetBSD
Classifier: Operating System :: POSIX :: BSD :: OpenBSD
+Classifier: Operating System :: POSIX :: BSD
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: POSIX :: SunOS/Solaris
Classifier: Operating System :: POSIX
@@ -433,5 +436,6 @@ Classifier: Topic :: System :: Hardware
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Networking :: Monitoring
Classifier: Topic :: System :: Networking
+Classifier: Topic :: System :: Operating System
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
diff --git a/psutil.egg-info/SOURCES.txt b/psutil.egg-info/SOURCES.txt
index add9bd0..4425e64 100644
--- a/psutil.egg-info/SOURCES.txt
+++ b/psutil.egg-info/SOURCES.txt
@@ -15,6 +15,13 @@ appveyor.yml
make.bat
setup.py
tox.ini
+.ci/README
+.ci/appveyor/README
+.ci/appveyor/install.ps1
+.ci/appveyor/run_with_compiler.cmd
+.ci/travis/README
+.ci/travis/install.sh
+.ci/travis/run.sh
docs/Makefile
docs/README
docs/conf.py
diff --git a/psutil/__init__.py b/psutil/__init__.py
index 3bbb46a..d46e034 100644
--- a/psutil/__init__.py
+++ b/psutil/__init__.py
@@ -133,6 +133,10 @@ elif sys.platform.startswith("sunos"):
from ._pssunos import CONN_BOUND # NOQA
from ._pssunos import CONN_IDLE # NOQA
+ # This is public API and it will be retrieved from _pssunos.py
+ # via sys.modules.
+ PROCFS_PATH = "/proc"
+
else: # pragma: no cover
raise NotImplementedError('platform %s is not supported' % sys.platform)
@@ -164,7 +168,7 @@ __all__ = [
]
__all__.extend(_psplatform.__extra__all__)
__author__ = "Giampaolo Rodola'"
-__version__ = "3.4.1"
+__version__ = "3.4.2"
version_info = tuple([int(num) for num in __version__.split('.')])
AF_LINK = _psplatform.AF_LINK
_TOTAL_PHYMEM = None
@@ -1138,7 +1142,7 @@ class Process(object):
class Popen(Process):
- """A more convenient interface to stdlib subprocess module.
+ """A more convenient interface to stdlib subprocess.Popen class.
It starts a sub process and deals with it exactly as when using
subprocess.Popen class but in addition also provides all the
properties and methods of psutil.Process class as a unified
diff --git a/psutil/_pssunos.py b/psutil/_pssunos.py
index c157409..4f3d6e1 100644
--- a/psutil/_pssunos.py
+++ b/psutil/_pssunos.py
@@ -19,10 +19,11 @@ from ._common import isfile_strict
from ._common import sockfam_to_enum
from ._common import socktype_to_enum
from ._common import usage_percent
+from ._compat import b
from ._compat import PY3
-__extra__all__ = ["CONN_IDLE", "CONN_BOUND"]
+__extra__all__ = ["CONN_IDLE", "CONN_BOUND", "PROCFS_PATH"]
PAGE_SIZE = os.sysconf('SC_PAGE_SIZE')
AF_LINK = cext_posix.AF_LINK
@@ -70,6 +71,13 @@ ZombieProcess = None
AccessDenied = None
TimeoutExpired = None
+
+# --- utils
+
+def get_procfs_path():
+ return sys.modules['psutil'].PROCFS_PATH
+
+
# --- functions
disk_io_counters = cext.disk_io_counters
@@ -122,7 +130,7 @@ def swap_memory():
def pids():
"""Returns a list of PIDs currently running on the system."""
- return [int(x) for x in os.listdir('/proc') if x.isdigit()]
+ return [int(x) for x in os.listdir(b(get_procfs_path())) if x.isdigit()]
def pid_exists(pid):
@@ -282,12 +290,13 @@ class Process(object):
@wrap_exceptions
def name(self):
# note: max len == 15
- return cext.proc_name_and_args(self.pid)[0]
+ return cext.proc_name_and_args(self.pid, get_procfs_path())[0]
@wrap_exceptions
def exe(self):
try:
- return os.readlink("/proc/%s/path/a.out" % self.pid)
+ return os.readlink(
+ "%s/%s/path/a.out" % (get_procfs_path(), self.pid))
except OSError:
pass # continue and guess the exe name from the cmdline
# Will be guessed later from cmdline but we want to explicitly
@@ -298,15 +307,16 @@ class Process(object):
@wrap_exceptions
def cmdline(self):
- return cext.proc_name_and_args(self.pid)[1].split(' ')
+ return cext.proc_name_and_args(
+ self.pid, get_procfs_path())[1].split(' ')
@wrap_exceptions
def create_time(self):
- return cext.proc_basic_info(self.pid)[3]
+ return cext.proc_basic_info(self.pid, get_procfs_path())[3]
@wrap_exceptions
def num_threads(self):
- return cext.proc_basic_info(self.pid)[5]
+ return cext.proc_basic_info(self.pid, get_procfs_path())[5]
@wrap_exceptions
def nice_get(self):
@@ -339,32 +349,36 @@ class Process(object):
@wrap_exceptions
def ppid(self):
- return cext.proc_basic_info(self.pid)[0]
+ return cext.proc_basic_info(self.pid, get_procfs_path())[0]
@wrap_exceptions
def uids(self):
- real, effective, saved, _, _, _ = cext.proc_cred(self.pid)
+ real, effective, saved, _, _, _ = \
+ cext.proc_cred(self.pid, get_procfs_path())
return _common.puids(real, effective, saved)
@wrap_exceptions
def gids(self):
- _, _, _, real, effective, saved = cext.proc_cred(self.pid)
+ _, _, _, real, effective, saved = \
+ cext.proc_cred(self.pid, get_procfs_path())
return _common.puids(real, effective, saved)
@wrap_exceptions
def cpu_times(self):
- user, system = cext.proc_cpu_times(self.pid)
+ user, system = cext.proc_cpu_times(self.pid, get_procfs_path())
return _common.pcputimes(user, system)
@wrap_exceptions
def terminal(self):
+ procfs_path = get_procfs_path()
hit_enoent = False
tty = wrap_exceptions(
- cext.proc_basic_info(self.pid)[0])
+ cext.proc_basic_info(self.pid, get_procfs_path())[0])
if tty != cext.PRNODEV:
for x in (0, 1, 2, 255):
try:
- return os.readlink('/proc/%d/path/%d' % (self.pid, x))
+ return os.readlink(
+ '%s/%d/path/%d' % (procfs_path, self.pid, x))
except OSError as err:
if err.errno == errno.ENOENT:
hit_enoent = True
@@ -372,7 +386,7 @@ class Process(object):
raise
if hit_enoent:
# raise NSP if the process disappeared on us
- os.stat('/proc/%s' % self.pid)
+ os.stat('%s/%s' % (procfs_path, self.pid))
@wrap_exceptions
def cwd(self):
@@ -380,17 +394,18 @@ class Process(object):
# it exists (ls shows it). If that's the case and the process
# is still alive return None (we can return None also on BSD).
# Reference: http://goo.gl/55XgO
+ procfs_path = get_procfs_path()
try:
- return os.readlink("/proc/%s/path/cwd" % self.pid)
+ return os.readlink("%s/%s/path/cwd" % (procfs_path, self.pid))
except OSError as err:
if err.errno == errno.ENOENT:
- os.stat("/proc/%s" % self.pid)
+ os.stat("%s/%s" % (procfs_path, self.pid))
return None
raise
@wrap_exceptions
def memory_info(self):
- ret = cext.proc_basic_info(self.pid)
+ ret = cext.proc_basic_info(self.pid, get_procfs_path())
rss, vms = ret[1] * 1024, ret[2] * 1024
return _common.pmem(rss, vms)
@@ -399,20 +414,21 @@ class Process(object):
@wrap_exceptions
def status(self):
- code = cext.proc_basic_info(self.pid)[6]
+ code = cext.proc_basic_info(self.pid, get_procfs_path())[6]
# XXX is '?' legit? (we're not supposed to return it anyway)
return PROC_STATUSES.get(code, '?')
@wrap_exceptions
def threads(self):
+ procfs_path = get_procfs_path()
ret = []
- tids = os.listdir('/proc/%d/lwp' % self.pid)
+ tids = os.listdir('%s/%d/lwp' % (procfs_path, self.pid))
hit_enoent = False
for tid in tids:
tid = int(tid)
try:
utime, stime = cext.query_process_thread(
- self.pid, tid)
+ self.pid, tid, procfs_path)
except EnvironmentError as err:
# ENOENT == thread gone in meantime
if err.errno == errno.ENOENT:
@@ -424,15 +440,16 @@ class Process(object):
ret.append(nt)
if hit_enoent:
# raise NSP if the process disappeared on us
- os.stat('/proc/%s' % self.pid)
+ os.stat('%s/%s' % (procfs_path, self.pid))
return ret
@wrap_exceptions
def open_files(self):
retlist = []
hit_enoent = False
- pathdir = '/proc/%d/path' % self.pid
- for fd in os.listdir('/proc/%d/fd' % self.pid):
+ procfs_path = get_procfs_path()
+ pathdir = '%s/%d/path' % (procfs_path, self.pid)
+ for fd in os.listdir('%s/%d/fd' % (procfs_path, self.pid)):
path = os.path.join(pathdir, fd)
if os.path.islink(path):
try:
@@ -448,7 +465,7 @@ class Process(object):
retlist.append(_common.popenfile(file, int(fd)))
if hit_enoent:
# raise NSP if the process disappeared on us
- os.stat('/proc/%s' % self.pid)
+ os.stat('%s/%s' % (procfs_path, self.pid))
return retlist
def _get_unix_sockets(self, pid):
@@ -492,7 +509,8 @@ class Process(object):
# process is no longer active so we force NSP in case the PID
# is no longer there.
if not ret:
- os.stat('/proc/%s' % self.pid) # will raise NSP if process is gone
+ # will raise NSP if process is gone
+ os.stat('%s/%s' % (get_procfs_path(), self.pid))
# UNIX sockets
if kind in ('all', 'unix'):
@@ -509,15 +527,17 @@ class Process(object):
return '%s-%s' % (hex(start)[2:].strip('L'),
hex(end)[2:].strip('L'))
+ procfs_path = get_procfs_path()
retlist = []
- rawlist = cext.proc_memory_maps(self.pid)
+ rawlist = cext.proc_memory_maps(self.pid, procfs_path)
hit_enoent = False
for item in rawlist:
addr, addrsize, perm, name, rss, anon, locked = item
addr = toaddr(addr, addrsize)
if not name.startswith('['):
try:
- name = os.readlink('/proc/%s/path/%s' % (self.pid, name))
+ name = os.readlink(
+ '%s/%s/path/%s' % (procfs_path, self.pid, name))
except OSError as err:
if err.errno == errno.ENOENT:
# sometimes the link may not be resolved by
@@ -526,23 +546,24 @@ class Process(object):
# unresolved link path.
# This seems an incosistency with /proc similar
# to: http://goo.gl/55XgO
- name = '/proc/%s/path/%s' % (self.pid, name)
+ name = '%s/%s/path/%s' % (procfs_path, self.pid, name)
hit_enoent = True
else:
raise
retlist.append((addr, perm, name, rss, anon, locked))
if hit_enoent:
# raise NSP if the process disappeared on us
- os.stat('/proc/%s' % self.pid)
+ os.stat('%s/%s' % (procfs_path, self.pid))
return retlist
@wrap_exceptions
def num_fds(self):
- return len(os.listdir("/proc/%s/fd" % self.pid))
+ return len(os.listdir("%s/%s/fd" % (get_procfs_path(), self.pid)))
@wrap_exceptions
def num_ctx_switches(self):
- return _common.pctxsw(*cext.proc_num_ctx_switches(self.pid))
+ return _common.pctxsw(
+ *cext.proc_num_ctx_switches(self.pid, get_procfs_path()))
@wrap_exceptions
def wait(self, timeout=None):
diff --git a/psutil/_psutil_sunos.c b/psutil/_psutil_sunos.c
index 3be1f54..3193305 100644
--- a/psutil/_psutil_sunos.c
+++ b/psutil/_psutil_sunos.c
@@ -88,12 +88,14 @@ psutil_file_to_struct(char *path, void *fstruct, size_t size) {
static PyObject *
psutil_proc_basic_info(PyObject *self, PyObject *args) {
int pid;
- char path[100];
+ char path[1000];
psinfo_t info;
+ const char *procfs_path;
- if (! PyArg_ParseTuple(args, "i", &pid))
+ if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
return NULL;
- sprintf(path, "/proc/%i/psinfo", pid);
+
+ sprintf(path, "%s/%i/psinfo", procfs_path, pid);
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
return Py_BuildValue("ikkdiiik",
@@ -115,12 +117,13 @@ psutil_proc_basic_info(PyObject *self, PyObject *args) {
static PyObject *
psutil_proc_name_and_args(PyObject *self, PyObject *args) {
int pid;
- char path[100];
+ char path[1000];
psinfo_t info;
+ const char *procfs_path;
- if (! PyArg_ParseTuple(args, "i", &pid))
+ if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
return NULL;
- sprintf(path, "/proc/%i/psinfo", pid);
+ sprintf(path, "%s/%i/psinfo", procfs_path, pid);
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
return Py_BuildValue("ss", info.pr_fname, info.pr_psargs);
@@ -133,12 +136,13 @@ psutil_proc_name_and_args(PyObject *self, PyObject *args) {
static PyObject *
psutil_proc_cpu_times(PyObject *self, PyObject *args) {
int pid;
- char path[100];
+ char path[1000];
pstatus_t info;
+ const char *procfs_path;
- if (! PyArg_ParseTuple(args, "i", &pid))
+ if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
return NULL;
- sprintf(path, "/proc/%i/status", pid);
+ sprintf(path, "%s/%i/status", procfs_path, pid);
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
// results are more precise than os.times()
@@ -154,12 +158,13 @@ psutil_proc_cpu_times(PyObject *self, PyObject *args) {
static PyObject *
psutil_proc_cred(PyObject *self, PyObject *args) {
int pid;
- char path[100];
+ char path[1000];
prcred_t info;
+ const char *procfs_path;
- if (! PyArg_ParseTuple(args, "i", &pid))
+ if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
return NULL;
- sprintf(path, "/proc/%i/cred", pid);
+ sprintf(path, "%s/%i/cred", procfs_path, pid);
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
return Py_BuildValue("iiiiii",
@@ -174,12 +179,13 @@ psutil_proc_cred(PyObject *self, PyObject *args) {
static PyObject *
psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) {
int pid;
- char path[100];
+ char path[1000];
prusage_t info;
+ const char *procfs_path;
- if (! PyArg_ParseTuple(args, "i", &pid))
+ if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
return NULL;
- sprintf(path, "/proc/%i/usage", pid);
+ sprintf(path, "%s/%i/usage", procfs_path, pid);
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
return Py_BuildValue("kk", info.pr_vctx, info.pr_ictx);
@@ -200,12 +206,13 @@ psutil_proc_num_ctx_switches(PyObject *self, PyObject *args) {
static PyObject*
proc_io_counters(PyObject* self, PyObject* args) {
int pid;
- char path[100];
+ char path[1000];
prusage_t info;
+ const char *procfs_path;
- if (! PyArg_ParseTuple(args, "i", &pid))
+ if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
return NULL;
- sprintf(path, "/proc/%i/usage", pid);
+ sprintf(path, "%s/%i/usage", procfs_path, pid);
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
@@ -229,12 +236,13 @@ proc_io_counters(PyObject* self, PyObject* args) {
static PyObject *
psutil_proc_query_thread(PyObject *self, PyObject *args) {
int pid, tid;
- char path[100];
+ char path[1000];
lwpstatus_t info;
+ const char *procfs_path;
- if (! PyArg_ParseTuple(args, "ii", &pid, &tid))
+ if (! PyArg_ParseTuple(args, "iis", &pid, &tid, &procfs_path))
return NULL;
- sprintf(path, "/proc/%i/lwp/%i/lwpstatus", pid, tid);
+ sprintf(path, "%s/%i/lwp/%i/lwpstatus", procfs_path, pid, tid);
if (! psutil_file_to_struct(path, (void *)&info, sizeof(info)))
return NULL;
return Py_BuildValue("dd",
@@ -545,7 +553,7 @@ static PyObject *
psutil_proc_memory_maps(PyObject *self, PyObject *args) {
int pid;
int fd = -1;
- char path[100];
+ char path[1000];
char perms[10];
char *name;
struct stat st;
@@ -557,20 +565,21 @@ psutil_proc_memory_maps(PyObject *self, PyObject *args) {
int nmap;
uintptr_t pr_addr_sz;
uintptr_t stk_base_sz, brk_base_sz;
+ const char *procfs_path;
PyObject *py_tuple = NULL;
PyObject *py_retlist = PyList_New(0);
if (py_retlist == NULL)
return NULL;
- if (! PyArg_ParseTuple(args, "i", &pid))
+ if (! PyArg_ParseTuple(args, "is", &pid, &procfs_path))
goto error;
... 47 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