Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into pslisten
Browse files Browse the repository at this point in the history
* origin/master: (121 commits)
  update HISTORY/README
  giampaolo#810: rename windows wheels to make pip 7.1.2 happy
  add doc warning about disk_io_counter() numbers which may overlap (se giampaolo#802)
  update HISTORY
  git travis/osx error
  fix typo
  fix travis err
  add STAT for ps.py
  Convert string arguments to bytes
  appveyor download script: check the num of download files and print a warning if it's < than expected
  win / CI: try not to upgrade pip version and see whether pip produces compatible wheels
  refactor makefile
  makefile refactoring
  makefile refactoring
  Updated to use better if/else/endif values (my bad) Updated HISTORY to explain better that Win XP still uses 32bit values Reverted test code, will add in a different PR
  Styling fixes (spaces instead of tabs)
  PEP 8 compliance and history update (Vista+ only for fix)
  Type fix
  Continue on RuntimeError when running df on partitions it can't run on
  Fix disk_usage test to use 1 kB block size due to issues with OS X
  Add comment lines to ifs for win versions
  Actually does need it in XP/2000 unfortunately
  Tried to keep the mingw32 support but win 7 sdk is causing issues
  Whoops, whitespace issue
  Add back in ws2tcpip.h in the proper place in Win XP / Win 2000
  Fixes for compiling on Win XP/Win 200
  Update HISTORY.rst with giampaolo#816 issue bug fix
  Fix for windows net_io_counters wrapping after 4.3GB due to MIB_IFROW using DWORD. Updated to use MIB_IF_ROW2 which gives ULONG values instead. This causes more breaking changes for Windows XP and all Windows versions less than Vista / Server 2008 meaning that it should have no problems working on Vista / Server 2008 and beyond.
  fix doc indentation
  doc indentation
  fix giampaolo#829: disk_usage().percent takes reserved root space into account
  giampaolo#829: add tests to compare disk_usage() with 'df' cmdline utility
  small refactoring
  update comment
  update badges
  move stuff around
  reorganize (move stuff in) _common.py
  def __all__ for _common.py module
  reorganize (move) test utils
  update __all__
  small @memoize refactoring
  Fix psutil.virtual_memory() type mismatch for NetBSD.
  prettyfy code
  prettyfy code
  update README
  Sets Makefile variable for imports compatible with Python 3.x
  fix linux test
  memory_maps: use bytes
  fir unpackment err
  refactor smaps code
  linux memory_maps refactoring
  fix typo
  update doc
  update version and HISTORY
  re-enable win services
  re-enable all tests on windows
  try to upgrade pip
  try to upgrade pip
  try to upgrade pip
  try to install pip globally
  try to upgrade pip
  force build of old 4.1.0 ver
  giampaolo#817: add script to download exes/whels from appveyor
  appveyor exp 5
  appveyor exp 4
  appveyor exp 3
  appveyor exp 2 appveyor/ci#806 (comment)
  appveyor exp appveyor/ci#806 (comment)
  appveyor experiment
  appveyor experiment
  appveyor: attempt differe VS config for py 3.5
  fix typo
  restore previous appveyor conf + try to add python 3.5 64 bits
  try easier appveyor conf, see pypa/packaging.python.org#172
  try to make appveyor create exes/wheels
  add freebsd dev notes
  refactor ctx switches
  uids/gids refactoring
  refactor num_threads
  more refactoring
  [Linux] Process.name() is 25% faster (on python 3)
  ignore me
  remove outdated test
  [Linux] speedup Process.status() by 28%
  [Linux] speedup Process.pid() by 20% by reading it from /proc/pid/stat instead of /proc/pid/status
  set ppid
  linux set ppid
  fix 813: have as_dict() ignore extraneous attribute names which getsattached to the Process instance
  pep8 fixes
  fix giampaolo#812: [NetBSD] fix compilation on NetBSD-5.x.
  build fix: MNT_RELATIME and MNT_EXTATTR are not available on NetBSD-5
  build fix: declare warn()
  update IDEAS
  fix win tests
  better AD error handling on win
  service descr: handle unicode errors
  service descr: handle empty description str
  check PyUnicodeDecode return value
  add services memory leak tests
  update doc
  ...
  • Loading branch information
nlevitt committed Jun 22, 2016
2 parents b68e141 + 978b673 commit 61bc5cc
Show file tree
Hide file tree
Showing 40 changed files with 3,072 additions and 1,250 deletions.
148 changes: 148 additions & 0 deletions .ci/appveyor/download_exes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
#!/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@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
import sys

from concurrent.futures import ThreadPoolExecutor


BASE_URL = 'https://ci.appveyor.com/api'
PY_VERSIONS = ['2.7', '3.3', '3.4', '3.5']


def term_supports_colors(file=sys.stdout):
try:
import curses
assert file.isatty()
curses.setupterm()
assert curses.tigetnum("colors") > 0
except Exception:
return False
else:
return True


if term_supports_colors():
def hilite(s, ok=True, bold=False):
"""Return an highlighted version of 'string'."""
attr = []
if ok is None: # no color
pass
elif ok: # green
attr.append('32')
else: # red
attr.append('31')
if bold:
attr.append('1')
return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), s)
else:
def hilite(s, *a, **k):
return s


def safe_makedirs(path):
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_fname = url.split('/')[-1]
local_fname = os.path.join('dist', local_fname)
print(local_fname)
safe_makedirs('dist')
r = requests.get(url, stream=True)
with open(local_fname, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
return local_fname


def get_file_urls(options):
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)
if not urls:
sys.exit("no artifacts found")
for url in sorted(urls, key=lambda x: os.path.basename(x)):
yield url


def rename_27_wheels():
# See: https://github.com/giampaolo/psutil/issues/810
src = 'dist/psutil-4.3.0-cp27-cp27m-win32.whl'
dst = 'dist/psutil-4.3.0-cp27-none-win32.whl'
print("rename: %s\n %s" % (src, dst))
os.rename(src, dst)
src = 'dist/psutil-4.3.0-cp27-cp27m-win_amd64.whl'
dst = 'dist/psutil-4.3.0-cp27-none-win_amd64.whl'
print("rename: %s\n %s" % (src, dst))
os.rename(src, dst)


def main(options):
files = []
safe_rmtree('dist')
with ThreadPoolExecutor(max_workers=multiprocessing.cpu_count()) as e:
for url in get_file_urls(options):
fut = e.submit(download_file, url)
files.append(fut.result())
# 2 exes (32 and 64 bit) and 2 wheels (32 and 64 bit) for each ver.
expected = len(PY_VERSIONS) * 4
got = len(files)
if expected != got:
print(hilite("expected %s files, got %s" % (expected, got), ok=False),
file=sys.stderr)
rename_27_wheels()


if __name__ == '__main__':
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)
71 changes: 56 additions & 15 deletions .ci/appveyor/run_with_compiler.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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%
Expand Down
2 changes: 1 addition & 1 deletion .git-pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import sys

def main():
out = subprocess.check_output("git diff --cached --name-only", shell=True)
files = [x for x in out.split('\n') if x.endswith('.py') and
files = [x for x in out.split(b'\n') if x.endswith(b'.py') and
os.path.exists(x)]

for path in files:
Expand Down
8 changes: 8 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,11 @@ D: sample code for process USS memory.
N: wxwright
W: https://github.com/wxwright
I: 776

N: Farhan Khan
E: khanzf@gmail.com
I: 823

N: Jake Omann
E: https://github.com/jhomann
I: 816
21 changes: 19 additions & 2 deletions DEVGUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ Typical process occurring when adding a new functionality (API):
``psutil/_psutil_{platform}.c`` (e.g. ``psutil/_psutil_linux.c``).
- write a generic test in ``psutil/tests/test_system.py`` or
``psutil/tests/test_process.py``.
- if possible, write a cross platform test in
- if possible, write a platform specific test in
``psutil/tests/test_{platform}.py`` (e.g. ``test_linux.py``).
This usually means testing the return value of the new feature against
a system CLI tool.
- update doc in ``doc/index.py``.
- update ``HISTORY.rst``.
- update ``README.rst`` (if necessary).
Expand Down Expand Up @@ -127,7 +129,7 @@ Documentation
- it uses `RsT syntax <http://docutils.sourceforge.net/docs/user/rst/quickref.html>`_
and it's built with `sphinx <http://sphinx-doc.org/>`_.
- doc can be built with ``make setup-dev-env; cd docs; make html``.
- public is hosted on http://pythonhosted.org/psutil/.
- public doc is hosted on http://pythonhosted.org/psutil/.
- it is uploaded on every new release with ``make upload-doc``.

=======================
Expand All @@ -139,6 +141,21 @@ These are note for myself (Giampaolo):
- make sure all tests pass and all builds are green.
- upload source tarball on PYPI with ``make upload-src``.
- upload exe and wheel files for windows on PYPI with ``make upload-all``.
- ...or by using atrifacts hosted on AppVeyor with ``make win-download-exes``
and ``make win-upload-exes``,
- upload updated doc on http://pythonhosted.org/psutil with ``make upload-doc``.
- GIT tag the new release with ``make git-tag-release``.
- post on psutil and python-announce mailing lists, twitter, g+, blog.

=============
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).
43 changes: 43 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
Bug tracker at https://github.com/giampaolo/psutil/issues

4.3.0 - 2016-06-18
==================

**Enhancements**

- #819: [Linux] different speedup improvements:
Process.ppid() is 20% faster
Process.status() is 28% faster
Process.name() is 25% faster
Process.num_threads is 20% faster on Python 3

**Bug fixes**

- #810: [Windows] Windows wheels are incompatible with pip 7.1.2.
- #812: [NetBSD] fix compilation on NetBSD-5.x.
- #823: [NetBSD] virtual_memory() raises TypeError on Python 3.
- #829: [UNIX] psutil.disk_usage() percent field takes root reserved space
into account.
- #816: [Windows] fixed net_io_counter() values wrapping after 4.3GB in
Windows Vista (NT 6.0) and above using 64bit values from newer win APIs.


4.2.0 - 2016-05-14
==================

**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
==================

Expand Down
18 changes: 7 additions & 11 deletions IDEAS
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 61bc5cc

Please sign in to comment.