[Python-modules-commits] [python-psutil] 01/09: Import python-psutil_4.2.0.orig.tar.gz
Sandro Tosi
morph at moszumanska.debian.org
Sat Jun 11 20:17:29 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 52757aa8b970726b8324740bca3a8ee00a58992c
Author: Sandro Tosi <morph at debian.org>
Date: Sat Jun 11 21:06:13 2016 +0100
Import python-psutil_4.2.0.orig.tar.gz
---
.ci/appveyor/download_exes.py | 92 ++++++++
.ci/appveyor/run_with_compiler.cmd | 71 ++++--
DEVGUIDE.rst | 12 ++
HISTORY.rst | 21 ++
IDEAS | 18 +-
INSTALL.rst | 4 +-
Makefile | 9 +
PKG-INFO | 29 ++-
README.rst | 27 ++-
appveyor.yml | 26 ++-
docs/index.rst | 79 ++++++-
make.bat | 7 +
psutil.egg-info/PKG-INFO | 29 ++-
psutil.egg-info/SOURCES.txt | 6 +-
psutil/__init__.py | 39 +++-
psutil/_common.py | 2 +-
psutil/_psbsd.py | 3 +-
psutil/_pslinux.py | 197 +++++++++--------
psutil/_psosx.py | 3 +-
psutil/_pssunos.py | 4 +-
psutil/_psutil_linux.c | 7 +-
psutil/_psutil_windows.c | 43 +++-
psutil/_pswindows.py | 201 ++++++++++++++++-
psutil/arch/windows/services.c | 431 +++++++++++++++++++++++++++++++++++++
psutil/arch/windows/services.h | 17 ++
psutil/tests/__init__.py | 2 +-
psutil/tests/test_linux.py | 104 +++++----
psutil/tests/test_memory_leaks.py | 23 +-
psutil/tests/test_misc.py | 10 +
psutil/tests/test_osx.py | 2 +-
psutil/tests/test_windows.py | 89 +++++++-
scripts/winservices.py | 56 +++++
setup.py | 1 +
33 files changed, 1463 insertions(+), 201 deletions(-)
diff --git a/.ci/appveyor/download_exes.py b/.ci/appveyor/download_exes.py
new file mode 100755
index 0000000..b7baf6b
--- /dev/null
+++ b/.ci/appveyor/download_exes.py
@@ -0,0 +1,92 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Script which downloads exe and wheel files hosted on AppVeyor:
+https://ci.appveyor.com/project/giampaolo/psutil
+Copied and readapted from the original recipe of Ibarra Corretge'
+<saghul at gmail.com>:
+http://code.saghul.net/index.php/2015/09/09/
+"""
+
+from __future__ import print_function
+import argparse
+import errno
+import multiprocessing
+import os
+import requests
+import shutil
+
+from concurrent.futures import ThreadPoolExecutor
+
+
+BASE_URL = 'https://ci.appveyor.com/api'
+
+
+def safe_makedirs(path):
+ try:
+ os.makedirs(path)
+ except OSError as err:
+ if err.errno == errno.EEXIST:
+ if not os.path.isdir(path):
+ raise
+ else:
+ raise
+
+
+def safe_rmtree(path):
+ def onerror(fun, path, excinfo):
+ exc = excinfo[1]
+ if exc.errno != errno.ENOENT:
+ raise
+
+ shutil.rmtree(path, onerror=onerror)
+
+
+def download_file(url):
+ local_filename = url.split('/')[-1]
+ local_filename = os.path.join('dist', local_filename)
+ print(local_filename)
+ safe_makedirs('dist')
+ r = requests.get(url, stream=True)
+ with open(local_filename, 'wb') as f:
+ for chunk in r.iter_content(chunk_size=1024):
+ if chunk: # filter out keep-alive new chunks
+ f.write(chunk)
+
+
+def get_file_urls(options):
+ session = requests.Session()
+ data = session.get(
+ BASE_URL + '/projects/' + options.user + '/' + options.project)
+ data = data.json()
+
+ urls = []
+ for job in (job['jobId'] for job in data['build']['jobs']):
+ job_url = BASE_URL + '/buildjobs/' + job + '/artifacts'
+ data = session.get(job_url)
+ data = data.json()
+ for item in data:
+ file_url = job_url + '/' + item['fileName']
+ urls.append(file_url)
+ for url in sorted(urls, key=lambda x: os.path.basename(x)):
+ yield url
+
+
+def main(options):
+ safe_rmtree('dist')
+ with ThreadPoolExecutor(max_workers=multiprocessing.cpu_count()) as e:
+ for url in get_file_urls(options):
+ e.submit(download_file, url)
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(
+ description='AppVeyor artifact downloader')
+ parser.add_argument('--user', required=True)
+ parser.add_argument('--project', required=True)
+ args = parser.parse_args()
+ main(args)
diff --git a/.ci/appveyor/run_with_compiler.cmd b/.ci/appveyor/run_with_compiler.cmd
index 3a472bc..5da547c 100644
--- a/.ci/appveyor/run_with_compiler.cmd
+++ b/.ci/appveyor/run_with_compiler.cmd
@@ -6,7 +6,8 @@
:: 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.
+:: 32 bit builds, and 64-bit builds for 3.5 and beyond, 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)
@@ -17,29 +18,69 @@
::
:: Author: Olivier Grisel
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
+::
+:: Notes about batch files for Python people:
+::
+:: Quotes in values are literally part of the values:
+:: SET FOO="bar"
+:: FOO is now five characters long: " b a r "
+:: If you don't want quotes, don't include them on the right-hand side.
+::
+:: The CALL lines at the end of this file look redundant, but if you move them
+:: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y
+:: case, I don't know why.
@ECHO OFF
SET COMMAND_TO_RUN=%*
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
+SET WIN_WDK=c:\Program Files (x86)\Windows Kits\10\Include\wdf
+
+:: Extract the major and minor versions, and allow for the minor version to be
+:: more than 9. This requires the version number to have two dots in it.
+SET MAJOR_PYTHON_VERSION=%PYTHON_VERSION:~0,1%
+IF "%PYTHON_VERSION:~3,1%" == "." (
+ SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,1%
+) ELSE (
+ SET MINOR_PYTHON_VERSION=%PYTHON_VERSION:~2,2%
+)
-SET MAJOR_PYTHON_VERSION="%PYTHON_VERSION:~0,1%"
-IF %MAJOR_PYTHON_VERSION% == "2" (
+:: Based on the Python version, determine what SDK version to use, and whether
+:: to set the SDK for 64-bit.
+IF %MAJOR_PYTHON_VERSION% == 2 (
SET WINDOWS_SDK_VERSION="v7.0"
-) ELSE IF %MAJOR_PYTHON_VERSION% == "3" (
- SET WINDOWS_SDK_VERSION="v7.1"
+ SET SET_SDK_64=Y
) ELSE (
- ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
- EXIT 1
+ IF %MAJOR_PYTHON_VERSION% == 3 (
+ SET WINDOWS_SDK_VERSION="v7.1"
+ IF %MINOR_PYTHON_VERSION% LEQ 4 (
+ SET SET_SDK_64=Y
+ ) ELSE (
+ SET SET_SDK_64=N
+ IF EXIST "%WIN_WDK%" (
+ :: See: https://connect.microsoft.com/VisualStudio/feedback/details/1610302/
+ REN "%WIN_WDK%" 0wdf
+ )
+ )
+ ) 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
+IF %PYTHON_ARCH% == 64 (
+ IF %SET_SDK_64% == Y (
+ 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 64 bit architecture
+ 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%
diff --git a/DEVGUIDE.rst b/DEVGUIDE.rst
index 6807413..691d5db 100644
--- a/DEVGUIDE.rst
+++ b/DEVGUIDE.rst
@@ -142,3 +142,15 @@ These are note for myself (Giampaolo):
- 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.
+
+=============
+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
diff --git a/HISTORY.rst b/HISTORY.rst
index 84187a1..e8a6ed9 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -1,5 +1,26 @@
Bug tracker at https://github.com/giampaolo/psutil/issues
+4.2.0 - 2016-05-14
+==================
+
+**Enhancements**
+
+- #795: [Windows] new APIs to deal with Windows services: win_service_iter()
+ and win_service_get().
+- #800: [Linux] psutil.virtual_memory() returns a new "shared" memory field.
+- #819: [Linux] speedup /proc parsing:
+ - 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**
+
+- #797: [Linux] net_if_stats() may raise OSError for certain NIC cards.
+- #813: Process.as_dict() should ignore extraneous attribute names which gets
+ attached to the Process instance.
+
+
4.1.0 - 2016-03-12
==================
diff --git a/IDEAS b/IDEAS
index 33178a7..9eb7d76 100644
--- a/IDEAS
+++ b/IDEAS
@@ -17,6 +17,11 @@ PLATFORMS
FEATURES
========
+- (Linux): from /proc/pid/stat we can also retrieve process and children guest
+ times (time spent running a virtual CPU for a guest OS).
+
+- #809: (Linux) per-process resource limits.
+
- (UNIX) process root (different from cwd)
- #782: (UNIX) process num of signals received.
@@ -91,18 +96,9 @@ FEATURES
Also, we can probably reimplement wait_pid() on POSIX which is currently
implemented as a busy-loop.
-- Certain systems provide CPU times about process children. On those systems
- Process.cpu_times() might return a (user, system, user_children,
- system_children) ntuple.
- - Linux: /proc/{PID}/stat
- - Solaris: pr_cutime and pr_cstime
- - FreeBSD: none
- - OSX: none
- - Windows: none
-
-- ...also, os.times() provides 'elapsed' times as well.
+- os.times() provides 'elapsed' times (cpu_times() might).
-- ...also Linux provides guest_time and cguest_time.
+- ...also guest_time and cguest_time on Linux.
- Enrich exception classes hierarchy on Python >= 3.3 / post PEP-3151 so that:
- NoSuchProcess inherits from ProcessLookupError
diff --git a/INSTALL.rst b/INSTALL.rst
index d2cb022..e9794c4 100644
--- a/INSTALL.rst
+++ b/INSTALL.rst
@@ -6,12 +6,12 @@ older Python version* `install pip <https://pip.pypa.io/en/latest/installing/>`_
Linux
=====
-Ubuntu / Debian::
+Ubuntu / Debian (use `python3-dev` for python 3)::
$ sudo apt-get install gcc python-dev
$ pip install psutil
-RedHat::
+RedHat (use `python3-devel` for python 3)::
$ sudo yum install gcc python-devel
$ pip install psutil
diff --git a/Makefile b/Makefile
index 3e6995d..a20f6a8 100644
--- a/Makefile
+++ b/Makefile
@@ -52,6 +52,7 @@ setup-dev-env: install-git-hooks
nose \
pep8 \
pyflakes \
+ requests \
sphinx \
sphinx-pypi-upload \
unittest2 \
@@ -126,3 +127,11 @@ git-tag-release:
install-git-hooks:
ln -sf ../../.git-pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
+
+# download exes/wheels hosted on appveyor
+win-download-exes:
+ $(PYTHON) .ci/appveyor/download_exes.py --user giampaolo --project psutil
+
+# upload exes/wheels in dist/* directory to PYPI
+win-upload-exes:
+ $(PYTHON) -m twine upload dist/*
diff --git a/PKG-INFO b/PKG-INFO
index 97e909d..1313744 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: psutil
-Version: 4.1.0
+Version: 4.2.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
@@ -51,7 +51,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
Summary
=======
- psutil (python system and process utilities) is a cross-platform library for
+ psutil (process and system utilities) is a cross-platform library for
retrieving information on **running processes** and **system utilization**
(CPU, memory, disks, network) in Python. It is useful mainly for **system
monitoring**, **profiling and limiting process resources** and **management of
@@ -134,7 +134,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
.. code-block:: python
>>> psutil.virtual_memory()
- svmem(total=8374149120, available=2081050624, percent=75.1, used=8074080256, free=300068864, active=3294920704, inactive=1361616896, buffers=529895424, cached=1251086336)
+ svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304)
>>> psutil.swap_memory()
sswap(total=2097147904, used=296128512, free=1801019392, percent=14.1, sin=304193536, sout=677842944)
>>>
@@ -340,6 +340,28 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
>>> gone, alive = psutil.wait_procs(procs_list, timeout=3, callback=on_terminate)
>>>
+ Windows services
+ ================
+
+ .. code-block:: python
+
+ >>> list(psutil.win_service_iter())
+ [<WindowsService(name='AeLookupSvc', display_name='Application Experience') at 38850096>,
+ <WindowsService(name='ALG', display_name='Application Layer Gateway Service') at 38850128>,
+ <WindowsService(name='APNMCP', display_name='Ask Update Service') at 38850160>,
+ <WindowsService(name='AppIDSvc', display_name='Application Identity') at 38850192>,
+ ...]
+ >>> s = psutil.win_service_get('alg')
+ >>> s.as_dict()
+ {'binpath': 'C:\\Windows\\System32\\alg.exe',
+ 'description': 'Provides support for 3rd party protocol plug-ins for Internet Connection Sharing',
+ 'display_name': 'Application Layer Gateway Service',
+ 'name': 'alg',
+ 'pid': None,
+ 'start_type': 'manual',
+ 'status': 'stopped',
+ 'username': 'NT AUTHORITY\\LocalService'}
+
======
Donate
======
@@ -364,6 +386,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
Timeline
========
+ - 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>`_
- 2016-01-15: `psutil-3.4.1.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.1.tar.gz>`_
diff --git a/README.rst b/README.rst
index 0cf5460..ffe3514 100644
--- a/README.rst
+++ b/README.rst
@@ -43,7 +43,7 @@ Quick links
Summary
=======
-psutil (python system and process utilities) is a cross-platform library for
+psutil (process and system utilities) is a cross-platform library for
retrieving information on **running processes** and **system utilization**
(CPU, memory, disks, network) in Python. It is useful mainly for **system
monitoring**, **profiling and limiting process resources** and **management of
@@ -126,7 +126,7 @@ Memory
.. code-block:: python
>>> psutil.virtual_memory()
- svmem(total=8374149120, available=2081050624, percent=75.1, used=8074080256, free=300068864, active=3294920704, inactive=1361616896, buffers=529895424, cached=1251086336)
+ svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304)
>>> psutil.swap_memory()
sswap(total=2097147904, used=296128512, free=1801019392, percent=14.1, sin=304193536, sout=677842944)
>>>
@@ -332,6 +332,28 @@ Further process APIs
>>> gone, alive = psutil.wait_procs(procs_list, timeout=3, callback=on_terminate)
>>>
+Windows services
+================
+
+.. code-block:: python
+
+ >>> list(psutil.win_service_iter())
+ [<WindowsService(name='AeLookupSvc', display_name='Application Experience') at 38850096>,
+ <WindowsService(name='ALG', display_name='Application Layer Gateway Service') at 38850128>,
+ <WindowsService(name='APNMCP', display_name='Ask Update Service') at 38850160>,
+ <WindowsService(name='AppIDSvc', display_name='Application Identity') at 38850192>,
+ ...]
+ >>> s = psutil.win_service_get('alg')
+ >>> s.as_dict()
+ {'binpath': 'C:\\Windows\\System32\\alg.exe',
+ 'description': 'Provides support for 3rd party protocol plug-ins for Internet Connection Sharing',
+ 'display_name': 'Application Layer Gateway Service',
+ 'name': 'alg',
+ 'pid': None,
+ 'start_type': 'manual',
+ 'status': 'stopped',
+ 'username': 'NT AUTHORITY\\LocalService'}
+
======
Donate
======
@@ -356,6 +378,7 @@ http://groups.google.com/group/psutil/
Timeline
========
+- 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>`_
- 2016-01-15: `psutil-3.4.1.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.1.tar.gz>`_
diff --git a/appveyor.yml b/appveyor.yml
index 838e754..52e56ba 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,3 +1,5 @@
+os: Visual Studio 2015
+
environment:
global:
@@ -42,11 +44,12 @@ environment:
PYTHON_VERSION: "3.4.x"
PYTHON_ARCH: "64"
- # XXX - not sure how to fix this:
- # https://ci.appveyor.com/project/giampaolo/psutil/build/354/job/uqf3rms55mrv90ju
- # - PYTHON: "C:\\Python35-x64"
- # PYTHON_VERSION: "3.5.x"
- # PYTHON_ARCH: "64"
+ - PYTHON: "C:\\Python35-x64"
+ PYTHON_VERSION: "3.5.x"
+ PYTHON_ARCH: "64"
+ ARCH: x86_64
+ VS_VER: "2015"
+ INSTANCENAME: "SQL2012SP1"
# Also build on a Python version not pre-installed by Appveyor.
# See: https://github.com/ogrisel/python-appveyor-demo/issues/10
@@ -61,9 +64,10 @@ 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')
- # - "%PYTHON%/python.exe C:/get-pip.py"
- # - "%PYTHON%/python.exe -m pip install ..."
- - "%WITH_COMPILER% %PYTHON%/Scripts/pip.exe install unittest2 ipaddress pypiwin32 wmi wheel setuptools --upgrade"
+ - "%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"
- "%WITH_COMPILER% %PYTHON%/python.exe setup.py build"
- "%WITH_COMPILER% %PYTHON%/python.exe setup.py build build_ext -i"
- "%WITH_COMPILER% %PYTHON%/python.exe setup.py develop"
@@ -73,10 +77,12 @@ install:
build: off
test_script:
+ - "%WITH_COMPILER% %PYTHON%/python -V"
- "%WITH_COMPILER% %PYTHON%/python psutil/tests/runner.py"
-# after_test:
-# - "%WITH_COMPILER% %PYTHON%/python setup.py bdist_wheel"
+after_test:
+ - "%WITH_COMPILER% %PYTHON%/python setup.py bdist_wheel"
+ - "%WITH_COMPILER% %PYTHON%/python setup.py bdist_wininst"
artifacts:
- path: dist\*
diff --git a/docs/index.rst b/docs/index.rst
index 90e2284..1873366 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -197,10 +197,10 @@ Memory
- **inactive** *(UNIX)*: memory that is marked as not used.
- **buffers** *(Linux, BSD)*: cache for things like file system metadata.
- **cached** *(Linux, BSD)*: cache for various things.
+ - **shared** *(Linux, BSD)*: memory that may be simultaneously accessed by
+ multiple processes.
- **wired** *(BSD, OSX)*: memory that is marked to always stay in RAM. It is
never moved to disk.
- - **shared** *(BSD)*: memory that may be simultaneously accessed by multiple
- processes.
The sum of **used** and **available** does not necessarily equal **total**.
On Windows **available** and **free** are the same.
@@ -210,7 +210,7 @@ Memory
>>> import psutil
>>> mem = psutil.virtual_memory()
>>> mem
- svmem(total=8374149120L, available=1247768576L, percent=85.1, used=8246628352L, free=127520768L, active=3208777728, inactive=1133408256, buffers=342413312L, cached=777834496)
+ 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:
@@ -218,6 +218,7 @@ Memory
...
>>>
+ .. versionchanged:: 4.2.0 added *shared* metrics on Linux.
.. function:: swap_memory()
@@ -1481,6 +1482,78 @@ Popen class
0
>>>
+Windows services
+================
+
+.. function:: win_service_iter()
+
+ Return an iterator yielding a :class:`WindowsService` class instance for all
+ Windows services installed.
+
+ .. versionadded:: 4.2.0
+ Availability: Windows
+
+.. function:: win_service_get(name)
+
+ Get a Windows service by name, returning a :class:`WindowsService` instance.
+ Raise :class:`psutil.NoSuchProcess` if no service with such name exists.
+
+ .. versionadded:: 4.2.0
+ Availability: Windows
+
+.. class:: WindowsService
+
+ Represents a Windows service with the given *name*. This class is returned
+ by :func:`win_service_iter` and :func:`win_service_get` functions and it is
+ not supposed to be instantiated directly.
+
+ .. method:: name()
+
+ The service name. This string is how a service is referenced and can be
+ passed to :func:`win_service_get` to get a new :class:`WindowsService`
+ instance.
+
+ .. method:: display_name()
+
+ The service display name. The value is cached when this class is
+ instantiated.
+
+ .. method:: binpath()
+
+ The fully qualified path to the service binary/exe file as a string,
+ including command line arguments.
+
+ .. method:: username()
+
+ The name of the user that owns this service.
+
+ .. method:: start_type()
+
+ A string which can either be `"automatic"`, `"manual"` or `"disabled"`.
+
+ .. method:: pid()
+
+ The process PID, if any, else `None`. This can be passed to
+ :class:`Process` class to control the service's process.
+
+ .. method:: status()
+
+ Service status as a string, which may be either `"running"`, `"paused"`,
+ `"start_pending"`, `"pause_pending"`, `"continue_pending"`,
+ `"stop_pending"` or `"stopped"`.
+
+ .. method:: description()
+
+ Service long description.
+
+ .. method:: as_dict()
+
+ Utility method retrieving all the information above as a dictionary.
+
+ .. versionadded:: 4.2.0
+ Availability: Windows
+
+
Constants
=========
diff --git a/make.bat b/make.bat
index f45466a..c4736e8 100644
--- a/make.bat
+++ b/make.bat
@@ -60,6 +60,7 @@ if "%1" == "help" (
echo test-memleaks run memory leak tests
echo test-process run process related tests
echo test-system run system APIs related tests
+ echo test-platform platform-specific Windows tests
echo uninstall uninstall
echo upload-all upload exes + wheels
goto :eof
@@ -126,6 +127,12 @@ if "%1" == "test-system" (
goto :eof
)
+f "%1" == "test-platform" (
+ call :install
+ %PYTHON% psutil\tests\test_windows.py
+ goto :eof
+)
+
if "%1" == "test-by-name" (
call :install
%PYTHON% -m nose psutil\tests\test_process.py psutil\tests\test_system.py psutil\tests\test_windows.py psutil\tests\test_misc.py --nocapture -v -m %2
diff --git a/psutil.egg-info/PKG-INFO b/psutil.egg-info/PKG-INFO
index 97e909d..1313744 100644
--- a/psutil.egg-info/PKG-INFO
+++ b/psutil.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: psutil
-Version: 4.1.0
+Version: 4.2.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
@@ -51,7 +51,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
Summary
=======
- psutil (python system and process utilities) is a cross-platform library for
+ psutil (process and system utilities) is a cross-platform library for
retrieving information on **running processes** and **system utilization**
(CPU, memory, disks, network) in Python. It is useful mainly for **system
monitoring**, **profiling and limiting process resources** and **management of
@@ -134,7 +134,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
.. code-block:: python
>>> psutil.virtual_memory()
- svmem(total=8374149120, available=2081050624, percent=75.1, used=8074080256, free=300068864, active=3294920704, inactive=1361616896, buffers=529895424, cached=1251086336)
+ svmem(total=10367352832, available=6472179712, percent=37.6, used=8186245120, free=2181107712, active=4748992512, inactive=2758115328, buffers=790724608, cached=3500347392, shared=787554304)
>>> psutil.swap_memory()
sswap(total=2097147904, used=296128512, free=1801019392, percent=14.1, sin=304193536, sout=677842944)
>>>
@@ -340,6 +340,28 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
>>> gone, alive = psutil.wait_procs(procs_list, timeout=3, callback=on_terminate)
>>>
+ Windows services
+ ================
+
+ .. code-block:: python
+
+ >>> list(psutil.win_service_iter())
+ [<WindowsService(name='AeLookupSvc', display_name='Application Experience') at 38850096>,
+ <WindowsService(name='ALG', display_name='Application Layer Gateway Service') at 38850128>,
+ <WindowsService(name='APNMCP', display_name='Ask Update Service') at 38850160>,
+ <WindowsService(name='AppIDSvc', display_name='Application Identity') at 38850192>,
+ ...]
+ >>> s = psutil.win_service_get('alg')
+ >>> s.as_dict()
+ {'binpath': 'C:\\Windows\\System32\\alg.exe',
+ 'description': 'Provides support for 3rd party protocol plug-ins for Internet Connection Sharing',
+ 'display_name': 'Application Layer Gateway Service',
+ 'name': 'alg',
+ 'pid': None,
+ 'start_type': 'manual',
+ 'status': 'stopped',
+ 'username': 'NT AUTHORITY\\LocalService'}
+
======
Donate
======
@@ -364,6 +386,7 @@ Description: .. image:: https://img.shields.io/pypi/dm/psutil.svg
Timeline
========
+ - 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>`_
- 2016-01-15: `psutil-3.4.1.tar.gz <https://pypi.python.org/packages/source/p/psutil/psutil-3.4.1.tar.gz>`_
diff --git a/psutil.egg-info/SOURCES.txt b/psutil.egg-info/SOURCES.txt
index 7fa432e..2494ab2 100644
--- a/psutil.egg-info/SOURCES.txt
+++ b/psutil.egg-info/SOURCES.txt
@@ -17,6 +17,7 @@ setup.py
tox.ini
.ci/README
.ci/appveyor/README
+.ci/appveyor/download_exes.py
.ci/appveyor/install.ps1
.ci/appveyor/run_with_compiler.cmd
.ci/travis/README
@@ -88,6 +89,8 @@ psutil/arch/windows/process_info.c
psutil/arch/windows/process_info.h
psutil/arch/windows/security.c
psutil/arch/windows/security.h
+psutil/arch/windows/services.c
+psutil/arch/windows/services.h
psutil/tests/README.rst
psutil/tests/__init__.py
psutil/tests/runner.py
@@ -116,4 +119,5 @@ scripts/procsmem.py
scripts/ps.py
scripts/pstree.py
scripts/top.py
-scripts/who.py
\ No newline at end of file
+scripts/who.py
+scripts/winservices.py
\ No newline at end of file
diff --git a/psutil/__init__.py b/psutil/__init__.py
index a8ab42d..1265768 100644
--- a/psutil/__init__.py
+++ b/psutil/__init__.py
@@ -187,7 +187,7 @@ __all__ = [
]
__all__.extend(_psplatform.__extra__all__)
__author__ = "Giampaolo Rodola'"
-__version__ = "4.1.0"
+__version__ = "4.2.0"
version_info = tuple([int(num) for num in __version__.split('.')])
AF_LINK = _psplatform.AF_LINK
_TOTAL_PHYMEM = None
@@ -461,12 +461,11 @@ class Process(object):
excluded_names = set(
['send_signal', 'suspend', 'resume', 'terminate', 'kill', 'wait',
'is_running', 'as_dict', 'parent', 'children', 'rlimit'])
+ valid_names = _process_attrnames - excluded_names
retdict = dict()
- ls = set(attrs or [x for x in dir(self)])
+ ls = set(attrs) if attrs else _process_attrnames
for name in ls:
- if name.startswith('_'):
- continue
- if name in excluded_names:
+ if name not in valid_names:
continue
try:
attr = getattr(self, name)
@@ -1274,6 +1273,9 @@ class Popen(Process):
return ret
+_process_attrnames = set([x for x in dir(Process) if not x.startswith('_')])
+
+
# =====================================================================
# --- system processes related functions
# =====================================================================
@@ -1984,6 +1986,29 @@ def users():
return _psplatform.users()
+# =====================================================================
+# --- Windows services
+# =====================================================================
+
+
+if WINDOWS:
+
+ def win_service_iter():
+ """Return a generator yielding a WindowsService instance for all
+ Windows services installed.
+ """
+ return _psplatform.win_service_iter()
+
+ def win_service_get(name):
+ """Get a Windows service by name.
+ Raise NoSuchProcess if no service with such name exists.
+ """
+ return _psplatform.win_service_get(name)
+
+
+# =====================================================================
+
+
def test(): # pragma: no cover
"""List info of all currently running processes emulating ps aux
output.
@@ -2041,8 +2066,8 @@ def test(): # pragma: no cover
del memoize, division, deprecated_method
-if sys.version_info < (3, 0):
- del num
+if sys.version_info[0] < 3:
+ del num, x
if __name__ == "__main__":
test()
diff --git a/psutil/_common.py b/psutil/_common.py
index fe68c6b..0c61207 100644
--- a/psutil/_common.py
+++ b/psutil/_common.py
@@ -198,7 +198,7 @@ def parse_environ_block(data):
equal_pos = data.find("=", pos, next_pos)
if equal_pos > pos:
key = data[pos:equal_pos]
- value = data[equal_pos+1:next_pos]
+ value = data[equal_pos + 1:next_pos]
# Windows expects environment variables to be uppercase only
if WINDOWS_:
key = key.upper()
diff --git a/psutil/_psbsd.py b/psutil/_psbsd.py
index 76d6d58..990ecd5 100644
--- a/psutil/_psbsd.py
+++ b/psutil/_psbsd.py
@@ -463,7 +463,8 @@ class Process(object):
@wrap_exceptions
def ppid(self):
- return cext.proc_ppid(self.pid)
+ self._ppid = cext.proc_ppid(self.pid)
+ return self._ppid
@wrap_exceptions
def uids(self):
diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py
index c03ba52..4fe87d6 100644
--- a/psutil/_pslinux.py
+++ b/psutil/_pslinux.py
@@ -155,6 +155,13 @@ def open_text(fname, **kwargs):
return open(fname, "rt", **kwargs)
+def decode(s):
+ if PY3:
+ return s.decode(encoding=FS_ENCODING, errors=ENCODING_ERRORS_HANDLER)
+ else:
+ return s
+
+
def get_procfs_path():
return sys.modules['psutil'].PROCFS_PATH
@@ -240,7 +247,7 @@ except Exception:
svmem = namedtuple(
'svmem', ['total', 'available', 'percent', 'used', 'free',
- 'active', 'inactive', 'buffers', 'cached'])
+ 'active', 'inactive', 'buffers', 'cached', 'shared'])
sdiskio = namedtuple('sdiskio', ['read_count', 'write_count',
'read_bytes', 'write_bytes',
'read_time', 'write_time',
@@ -266,36 +273,59 @@ def virtual_memory():
total *= unit_multiplier
free *= unit_multiplier
buffers *= unit_multiplier
- # XXX: tis is currently not used (neither returned) because it's
- # always 0. It would be nice to have though ('free' provides it).
- # shared *= unit_multiplier
+ # Note: this (on my Ubuntu 14.04, kernel 3.13 at least) may be 0.
+ # If so, it will be determined from /proc/meminfo.
+ shared *= unit_multiplier or None
+ if shared == 0:
+ shared = None
cached = active = inactive = None
with open_binary('%s/meminfo' % get_procfs_path()) as f:
for line in f:
- if line.startswith(b"Cached:"):
+ if cached is None and line.startswith(b"Cached:"):
cached = int(line.split()[1]) * 1024
- elif line.startswith(b"Active:"):
+ elif active is None and line.startswith(b"Active:"):
active = int(line.split()[1]) * 1024
- elif line.startswith(b"Inactive:"):
+ elif inactive is None and line.startswith(b"Inactive:"):
inactive = int(line.split()[1]) * 1024
- if (cached is not None and
- active is not None and
- inactive is not None):
- break
- else:
- # we might get here when dealing with exotic Linux flavors, see:
- # https://github.com/giampaolo/psutil/issues/313
- msg = "'cached', 'active' and 'inactive' memory stats couldn't " \
- "be determined and were set to 0"
- warnings.warn(msg, RuntimeWarning)
- cached = active = inactive = 0
+ # From "man free":
+ # The shared memory column represents either the MemShared
+ # value (2.4 kernels) or the Shmem value (2.6+ kernels) taken
+ # from the /proc/meminfo file. The value is zero if none of
+ # the entries is exported by the kernel.
+ elif shared is None and \
+ line.startswith(b"MemShared:") or \
+ line.startswith(b"Shmem:"):
+ shared = int(line.split()[1]) * 1024
+
+ missing = []
+ if cached is None:
+ missing.append('cached')
+ cached = 0
+ if active is None:
+ missing.append('active')
+ active = 0
+ if inactive is None:
+ missing.append('inactive')
+ inactive = 0
+ if shared is None:
+ missing.append('shared')
+ shared = 0
+ if missing:
+ msg = "%s memory stats couldn't be determined and %s set to 0" % (
+ ", ".join(missing),
+ "was" if len(missing) == 1 else "were")
+ warnings.warn(msg, RuntimeWarning)
+ # Note: this value matches "htop" perfectly.
avail = free + buffers + cached
+ # Note: this value matches "free", but not all the time, see:
+ # https://github.com/giampaolo/psutil/issues/685#issuecomment-202914057
used = total - free
+ # Note: this value matches "htop" perfectly.
percent = usage_percent((total - avail), total, _round=1)
return svmem(total, avail, percent, used, free,
- active, inactive, buffers, cached)
+ active, inactive, buffers, cached, shared)
def swap_memory():
@@ -920,12 +950,34 @@ class Process(object):
... 1475 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