summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ifconfig.py56
-rwxr-xr-xscripts/internal/download_exes.py6
-rwxr-xr-xscripts/internal/generate_manifest.py8
-rwxr-xr-xscripts/internal/print_announce.py9
-rwxr-xr-xscripts/internal/winmake.py67
-rwxr-xr-xscripts/procinfo.py3
6 files changed, 86 insertions, 63 deletions
diff --git a/scripts/ifconfig.py b/scripts/ifconfig.py
index b823b374..e2a9ce53 100755
--- a/scripts/ifconfig.py
+++ b/scripts/ifconfig.py
@@ -10,34 +10,34 @@ A clone of 'ifconfig' on UNIX.
$ python scripts/ifconfig.py
lo:
stats : speed=0MB, duplex=?, mtu=65536, up=yes
- incoming : bytes=6889336, pkts=84032, errs=0, drops=0
- outgoing : bytes=6889336, pkts=84032, errs=0, drops=0
+ incoming : bytes=1.95M, pkts=22158, errs=0, drops=0
+ outgoing : bytes=1.95M, pkts=22158, errs=0, drops=0
IPv4 address : 127.0.0.1
netmask : 255.0.0.0
IPv6 address : ::1
netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
MAC address : 00:00:00:00:00:00
-vboxnet0:
- stats : speed=10MB, duplex=full, mtu=1500, up=yes
- incoming : bytes=0, pkts=0, errs=0, drops=0
- outgoing : bytes=1622766, pkts=9102, errs=0, drops=0
- IPv4 address : 192.168.33.1
- broadcast : 192.168.33.255
- netmask : 255.255.255.0
- IPv6 address : fe80::800:27ff:fe00:0%vboxnet0
+docker0:
+ stats : speed=0MB, duplex=?, mtu=1500, up=yes
+ incoming : bytes=3.48M, pkts=65470, errs=0, drops=0
+ outgoing : bytes=164.06M, pkts=112993, errs=0, drops=0
+ IPv4 address : 172.17.0.1
+ broadcast : 172.17.0.1
+ netmask : 255.255.0.0
+ IPv6 address : fe80::42:27ff:fe5e:799e%docker0
netmask : ffff:ffff:ffff:ffff::
- MAC address : 0a:00:27:00:00:00
+ MAC address : 02:42:27:5e:79:9e
broadcast : ff:ff:ff:ff:ff:ff
-eth0:
+wlp3s0:
stats : speed=0MB, duplex=?, mtu=1500, up=yes
- incoming : bytes=18905596301, pkts=15178374, errs=0, drops=21
- outgoing : bytes=1913720087, pkts=9543981, errs=0, drops=0
- IPv4 address : 10.0.0.3
+ incoming : bytes=7.04G, pkts=5637208, errs=0, drops=0
+ outgoing : bytes=372.01M, pkts=3200026, errs=0, drops=0
+ IPv4 address : 10.0.0.2
broadcast : 10.255.255.255
netmask : 255.0.0.0
- IPv6 address : fe80::7592:1dcf:bcb7:98d6%wlp3s0
+ IPv6 address : fe80::ecb3:1584:5d17:937%wlp3s0
netmask : ffff:ffff:ffff:ffff::
MAC address : 48:45:20:59:a4:0c
broadcast : ff:ff:ff:ff:ff:ff
@@ -62,6 +62,24 @@ duplex_map = {
}
+def bytes2human(n):
+ """
+ >>> bytes2human(10000)
+ '9.8 K'
+ >>> bytes2human(100001221)
+ '95.4 M'
+ """
+ symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y')
+ prefix = {}
+ for i, s in enumerate(symbols):
+ prefix[s] = 1 << (i + 1) * 10
+ for s in reversed(symbols):
+ if n >= prefix[s]:
+ value = float(n) / prefix[s]
+ return '%.2f%s' % (value, s)
+ return '%.2fB' % (n)
+
+
def main():
stats = psutil.net_if_stats()
io_counters = psutil.net_io_counters(pernic=True)
@@ -77,10 +95,12 @@ def main():
io = io_counters[nic]
print(" incoming : ", end='')
print("bytes=%s, pkts=%s, errs=%s, drops=%s" % (
- io.bytes_recv, io.packets_recv, io.errin, io.dropin))
+ bytes2human(io.bytes_recv), io.packets_recv, io.errin,
+ io.dropin))
print(" outgoing : ", end='')
print("bytes=%s, pkts=%s, errs=%s, drops=%s" % (
- io.bytes_sent, io.packets_sent, io.errout, io.dropout))
+ bytes2human(io.bytes_sent), io.packets_sent, io.errout,
+ io.dropout))
for addr in addrs:
print(" %-4s" % af_map.get(addr.family, addr.family), end="")
print(" address : %s" % addr.address)
diff --git a/scripts/internal/download_exes.py b/scripts/internal/download_exes.py
index 9688919b..1b004428 100755
--- a/scripts/internal/download_exes.py
+++ b/scripts/internal/download_exes.py
@@ -25,7 +25,7 @@ from psutil import __version__ as PSUTIL_VERSION
BASE_URL = 'https://ci.appveyor.com/api'
-PY_VERSIONS = ['2.7', '3.3', '3.4', '3.5', '3.6']
+PY_VERSIONS = ['2.7', '3.4', '3.5', '3.6']
TIMEOUT = 30
COLORS = True
@@ -170,8 +170,8 @@ def main(options):
completed += 1
print("downloaded %-45s %s" % (
local_fname, bytes2human(os.path.getsize(local_fname))))
- # 2 exes (32 and 64 bit) and 2 wheels (32 and 64 bit) for each ver.
- expected = len(PY_VERSIONS) * 4
+ # 2 wheels (32 and 64 bit) per supported python version
+ expected = len(PY_VERSIONS) * 2
if expected != completed:
return exit("expected %s files, got %s" % (expected, completed))
if exc:
diff --git a/scripts/internal/generate_manifest.py b/scripts/internal/generate_manifest.py
index 8b6b4f5f..3511b749 100755
--- a/scripts/internal/generate_manifest.py
+++ b/scripts/internal/generate_manifest.py
@@ -12,6 +12,10 @@ import os
import subprocess
+IGNORED_EXTS = ('.png', '.jpg', '.jpeg')
+IGNORED_FILES = ('.travis.yml', 'appveyor.yml')
+
+
def sh(cmd):
return subprocess.check_output(
cmd, shell=True, universal_newlines=True).strip()
@@ -21,8 +25,8 @@ def main():
files = sh("git ls-files").split('\n')
for file in files:
if file.startswith('.ci/') or \
- os.path.splitext(file)[1] in ('.png', '.jpg') or \
- file in ('.travis.yml', 'appveyor.yml'):
+ os.path.splitext(file)[1].lower() in IGNORED_EXTS or \
+ file in IGNORED_FILES:
continue
print("include " + file)
diff --git a/scripts/internal/print_announce.py b/scripts/internal/print_announce.py
index e47911c2..1c2b9e11 100755
--- a/scripts/internal/print_announce.py
+++ b/scripts/internal/print_announce.py
@@ -19,7 +19,7 @@ HISTORY = os.path.abspath(os.path.join(HERE, '../../HISTORY.rst'))
PRJ_NAME = 'psutil'
PRJ_URL_HOME = 'https://github.com/giampaolo/psutil'
-PRJ_URL_DOC = 'http://pythonhosted.org/psutil'
+PRJ_URL_DOC = 'http://psutil.readthedocs.io'
PRJ_URL_DOWNLOAD = 'https://pypi.python.org/pypi/psutil'
PRJ_URL_WHATSNEW = \
'https://github.com/giampaolo/psutil/blob/master/HISTORY.rst'
@@ -39,10 +39,9 @@ monitoring, profiling and limiting process resources and management of \
running processes. It implements many functionalities offered by command \
line tools 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 versions from 2.6 \
-to 3.5 (users of Python 2.4 and 2.5 may use 2.1.3 version). PyPy is also \
-known to work.
+currently supports Linux, Windows, OSX, Sun Solaris, FreeBSD, OpenBSD, NetBSD \
+and AIX, both 32-bit and 64-bit architectures, with Python versions from 2.6 \
+to 3.6. PyPy is also known to work.
What's new
==========
diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py
index 138a0b0c..548f7a8e 100755
--- a/scripts/internal/winmake.py
+++ b/scripts/internal/winmake.py
@@ -174,6 +174,12 @@ def recursive_rm(*patterns):
safe_rmtree(os.path.join(root, dir))
+def test_setup():
+ os.environ['PYTHONWARNINGS'] = 'all'
+ os.environ['PSUTIL_TESTING'] = '1'
+ os.environ['PSUTIL_DEBUG'] = '1'
+
+
# ===================================================================
# commands
# ===================================================================
@@ -205,13 +211,6 @@ def build():
@cmd
-def build_exe():
- """Create exe file."""
- build()
- sh("%s setup.py bdist_wininst" % PYTHON)
-
-
-@cmd
def build_wheel():
"""Create wheel file."""
build()
@@ -328,15 +327,15 @@ def flake8():
py_files = py_files.decode()
py_files = [x for x in py_files.split() if x.endswith('.py')]
py_files = ' '.join(py_files)
- sh("%s -Wa -m flake8 %s" % (PYTHON, py_files), nolog=True)
+ sh("%s -m flake8 %s" % (PYTHON, py_files), nolog=True)
@cmd
def test():
"""Run tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa %s" % (PYTHON, TSCRIPT))
+ test_setup()
+ sh("%s %s" % (PYTHON, TSCRIPT))
@cmd
@@ -344,8 +343,8 @@ def coverage():
"""Run coverage tests."""
# Note: coverage options are controlled by .coveragerc file
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m coverage run %s" % (PYTHON, TSCRIPT))
+ test_setup()
+ sh("%s -m coverage run %s" % (PYTHON, TSCRIPT))
sh("%s -m coverage report" % PYTHON)
sh("%s -m coverage html" % PYTHON)
sh("%s -m webbrowser -t htmlcov/index.html" % PYTHON)
@@ -355,56 +354,56 @@ def coverage():
def test_process():
"""Run process tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m unittest -v psutil.tests.test_process" % PYTHON)
+ test_setup()
+ sh("%s -m unittest -v psutil.tests.test_process" % PYTHON)
@cmd
def test_system():
"""Run system tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m unittest -v psutil.tests.test_system" % PYTHON)
+ test_setup()
+ sh("%s -m unittest -v psutil.tests.test_system" % PYTHON)
@cmd
def test_platform():
"""Run windows only tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m unittest -v psutil.tests.test_windows" % PYTHON)
+ test_setup()
+ sh("%s -m unittest -v psutil.tests.test_windows" % PYTHON)
@cmd
def test_misc():
"""Run misc tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m unittest -v psutil.tests.test_misc" % PYTHON)
+ test_setup()
+ sh("%s -m unittest -v psutil.tests.test_misc" % PYTHON)
@cmd
def test_unicode():
"""Run unicode tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m unittest -v psutil.tests.test_unicode" % PYTHON)
+ test_setup()
+ sh("%s -m unittest -v psutil.tests.test_unicode" % PYTHON)
@cmd
def test_connections():
"""Run connections tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m unittest -v psutil.tests.test_connections" % PYTHON)
+ test_setup()
+ sh("%s -m unittest -v psutil.tests.test_connections" % PYTHON)
@cmd
def test_contracts():
"""Run contracts tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m unittest -v psutil.tests.test_contracts" % PYTHON)
+ test_setup()
+ sh("%s -m unittest -v psutil.tests.test_contracts" % PYTHON)
@cmd
@@ -416,8 +415,8 @@ def test_by_name():
except IndexError:
sys.exit('second arg missing')
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa -m unittest -v %s" % (PYTHON, name))
+ test_setup()
+ sh("%s -m unittest -v %s" % (PYTHON, name))
@cmd
@@ -429,16 +428,16 @@ def test_script():
except IndexError:
sys.exit('second arg missing')
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa %s" % (PYTHON, name))
+ test_setup()
+ sh("%s %s" % (PYTHON, name))
@cmd
def test_memleaks():
"""Run memory leaks tests"""
install()
- os.environ['PSUTIL_TESTING'] = '1'
- sh("%s -Wa psutil\\tests\\test_memory_leaks.py" % PYTHON)
+ test_setup()
+ sh("%s psutil\\tests\\test_memory_leaks.py" % PYTHON)
@cmd
@@ -467,8 +466,8 @@ def set_python(s):
# try to look for a python installation
orig = s
s = s.replace('.', '')
- vers = ('26', '27', '33', '34', '35', '36', '37',
- '26-64', '27-64', '33-64', '34-64', '35-64', '36-64', '37-64')
+ vers = ('26', '27', '34', '35', '36', '37',
+ '26-64', '27-64', '34-64', '35-64', '36-64', '37-64')
for v in vers:
if s == v:
path = 'C:\\python%s\python.exe' % s
diff --git a/scripts/procinfo.py b/scripts/procinfo.py
index d8625560..54205de3 100755
--- a/scripts/procinfo.py
+++ b/scripts/procinfo.py
@@ -225,7 +225,8 @@ def run(pid, verbose=False):
if 'io_counters' in pinfo:
print_('I/O', str_ntuple(pinfo['io_counters'], bytes2human=True))
- print_("ctx-switches", str_ntuple(pinfo['num_ctx_switches']))
+ if 'num_ctx_switches' in pinfo:
+ print_("ctx-switches", str_ntuple(pinfo['num_ctx_switches']))
if pinfo['children']:
template = "%-6s %s"
print_("children", template % ("PID", "NAME"))