Skip to content

Commit

Permalink
#521 remove python 2.4 and 2.5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Nov 1, 2014
1 parent f8e338c commit 02d58e9
Show file tree
Hide file tree
Showing 27 changed files with 342 additions and 782 deletions.
2 changes: 0 additions & 2 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ Compiling on Windows using Visual Studio
To use Visual Studio to compile psutil you must have the same version of
Visual Studio used to compile your installation of Python which is::

Python 2.4: VS 2003
Python 2.5: VS 2003
Python 2.6: VS 2008
Python 2.7: VS 2008
Python 3.3+: VS 2010
Expand Down
14 changes: 2 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,10 @@ build: clean
$(PYTHON) setup.py build

install: build
if test $(PYTHON) = python2.4; then \
$(PYTHON) setup.py install; \
elif test $(PYTHON) = python2.5; then \
$(PYTHON) setup.py install; \
else \
$(PYTHON) setup.py install --user; \
fi
$(PYTHON) setup.py install --user; \

uninstall:
if test $(PYTHON) = python2.4; then \
pip-2.4 uninstall -y -v psutil; \
else \
cd ..; $(PYTHON) -m pip uninstall -y -v psutil; \
fi
cd ..; $(PYTHON) -m pip uninstall -y -v psutil; \

test: install
$(PYTHON) $(TSCRIPT)
Expand Down
26 changes: 6 additions & 20 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,17 @@

import datetime
import os
import sys


if sys.version_info >= (3, ):
def u(s):
return s
else:
def u(s):
if not isinstance(s, unicode): # NOQA
s = unicode(s, "unicode_escape") # NOQA
return s


PROJECT_NAME = u("psutil")
AUTHOR = u("Giampaolo Rodola'")
PROJECT_NAME = "psutil"
AUTHOR = "Giampaolo Rodola'"
THIS_YEAR = str(datetime.datetime.now().year)
HERE = os.path.abspath(os.path.dirname(__file__))


def get_version():
INIT = os.path.abspath(os.path.join(HERE, '../psutil/__init__.py'))
f = open(INIT, 'r')
try:
with open(INIT, 'r') as f:
for line in f:
if line.startswith('__version__'):
ret = eval(line.strip().split(' = ')[1])
Expand All @@ -46,8 +34,6 @@ def get_version():
return ret
else:
raise ValueError("couldn't find version string")
finally:
f.close()

VERSION = get_version()

Expand Down Expand Up @@ -77,7 +63,7 @@ def get_version():

# General information about the project.
project = PROJECT_NAME
copyright = u('2009-%s, %s' % (THIS_YEAR, AUTHOR))
copyright = '2009-%s, %s' % (THIS_YEAR, AUTHOR)

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -223,7 +209,7 @@ def get_version():
# [howto/manual]).
latex_documents = [
('index', '%s.tex' % PROJECT_NAME,
u('%s documentation') % PROJECT_NAME, AUTHOR),
'%s documentation' % PROJECT_NAME, AUTHOR),
]

# The name of an image file (relative to this directory) to place at
Expand Down Expand Up @@ -255,7 +241,7 @@ def get_version():
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', PROJECT_NAME, u('%s documentation') % PROJECT_NAME, [AUTHOR], 1)
('index', PROJECT_NAME, '%s documentation' % PROJECT_NAME, [AUTHOR], 1)
]

# If true, show URL addresses after external links.
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ From project's home page:
ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap*.
It currently supports **Linux, Windows, OSX, FreeBSD** and **Sun Solaris**,
both **32-bit** and **64-bit** architectures, with Python versions from
**2.4** to **3.4**.
**2.6** to **3.4**.
`Pypy <http://pypy.org/>`__ is also known to work.

The psutil documentation you're reading is distributed as a single HTML page.
Expand Down
7 changes: 3 additions & 4 deletions examples/disk_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import sys
import os
import psutil
from psutil._compat import print_


def bytes2human(n):
Expand All @@ -40,8 +39,8 @@ def bytes2human(n):

def main():
templ = "%-17s %8s %8s %8s %5s%% %9s %s"
print_(templ % ("Device", "Total", "Used", "Free", "Use ", "Type",
"Mount"))
print(templ % ("Device", "Total", "Used", "Free", "Use ", "Type",
"Mount"))
for part in psutil.disk_partitions(all=False):
if os.name == 'nt':
if 'cdrom' in part.opts or part.fstype == '':
Expand All @@ -50,7 +49,7 @@ def main():
# partition or just hang.
continue
usage = psutil.disk_usage(part.mountpoint)
print_(templ % (
print(templ % (
part.device,
bytes2human(usage.total),
bytes2human(usage.used),
Expand Down
7 changes: 3 additions & 4 deletions examples/free.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,22 @@
"""

import psutil
from psutil._compat import print_


def main():
virt = psutil.virtual_memory()
swap = psutil.swap_memory()
templ = "%-7s %10s %10s %10s %10s %10s %10s"
print_(templ % ('', 'total', 'used', 'free', 'shared', 'buffers', 'cache'))
print_(templ % (
print(templ % ('', 'total', 'used', 'free', 'shared', 'buffers', 'cache'))
print(templ % (
'Mem:',
int(virt.total / 1024),
int(virt.used / 1024),
int(virt.free / 1024),
int(getattr(virt, 'shared', 0) / 1024),
int(getattr(virt, 'buffers', 0) / 1024),
int(getattr(virt, 'cached', 0) / 1024)))
print_(templ % (
print(templ % (
'Swap:', int(swap.total / 1024),
int(swap.used / 1024),
int(swap.free / 1024),
Expand Down
7 changes: 3 additions & 4 deletions examples/meminfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"""

import psutil
from psutil._compat import print_


def bytes2human(n):
Expand All @@ -56,13 +55,13 @@ def pprint_ntuple(nt):
value = getattr(nt, name)
if name != 'percent':
value = bytes2human(value)
print_('%-10s : %7s' % (name.capitalize(), value))
print('%-10s : %7s' % (name.capitalize(), value))


def main():
print_('MEMORY\n------')
print('MEMORY\n------')
pprint_ntuple(psutil.virtual_memory())
print_('\nSWAP\n----')
print('\nSWAP\n----')
pprint_ntuple(psutil.swap_memory())

if __name__ == '__main__':
Expand Down
5 changes: 2 additions & 3 deletions examples/netstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from socket import AF_INET, SOCK_STREAM, SOCK_DGRAM

import psutil
from psutil._compat import print_


AD = "-"
Expand All @@ -38,7 +37,7 @@

def main():
templ = "%-5s %-30s %-30s %-13s %-6s %s"
print_(templ % (
print(templ % (
"Proto", "Local address", "Remote address", "Status", "PID",
"Program name"))
proc_names = {}
Expand All @@ -52,7 +51,7 @@ def main():
raddr = ""
if c.raddr:
raddr = "%s:%s" % (c.raddr)
print_(templ % (
print(templ % (
proto_map[(c.family, c.type)],
laddr,
raddr or AD,
Expand Down
11 changes: 5 additions & 6 deletions examples/pmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,25 @@
import sys

import psutil
from psutil._compat import print_


def main():
if len(sys.argv) != 2:
sys.exit('usage: pmap <pid>')
p = psutil.Process(int(sys.argv[1]))
print_("pid=%s, name=%s" % (p.pid, p.name()))
print("pid=%s, name=%s" % (p.pid, p.name()))
templ = "%-16s %10s %-7s %s"
print_(templ % ("Address", "RSS", "Mode", "Mapping"))
print(templ % ("Address", "RSS", "Mode", "Mapping"))
total_rss = 0
for m in p.memory_maps(grouped=False):
total_rss += m.rss
print_(templ % (
print(templ % (
m.addr.split('-')[0].zfill(16),
str(m.rss / 1024) + 'K',
m.perms,
m.path))
print_("-" * 33)
print_(templ % ("Total", str(total_rss / 1024) + 'K', '', ''))
print("-" * 33)
print(templ % ("Total", str(total_rss / 1024) + 'K', '', ''))

if __name__ == '__main__':
main()
4 changes: 2 additions & 2 deletions examples/process_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def run(pid):
try:
p = psutil.Process(pid)
pinfo = p.as_dict(ad_value=ACCESS_DENIED)
except psutil.NoSuchProcess:
sys.exit(str(sys.exc_info()[1]))
except psutil.NoSuchProcess as err:
sys.exit(str(err))

try:
parent = p.parent()
Expand Down
26 changes: 13 additions & 13 deletions examples/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import time

import psutil
from psutil._compat import print_


def main():
Expand All @@ -27,8 +26,8 @@ def main():
if os.name == 'posix':
attrs.append('uids')
attrs.append('terminal')
print_(templ % ("USER", "PID", "%CPU", "%MEM", "VSZ", "RSS", "TTY",
"START", "TIME", "COMMAND"))
print(templ % ("USER", "PID", "%CPU", "%MEM", "VSZ", "RSS", "TTY",
"START", "TIME", "COMMAND"))
for p in psutil.process_iter():
try:
pinfo = p.as_dict(attrs, ad_value='')
Expand Down Expand Up @@ -65,16 +64,17 @@ def main():
int(pinfo['memory_info'].rss / 1024) or '?'
memp = pinfo['memory_percent'] and \
round(pinfo['memory_percent'], 1) or '?'
print_(templ % (user[:10],
pinfo['pid'],
pinfo['cpu_percent'],
memp,
vms,
rss,
pinfo.get('terminal', '') or '?',
ctime,
cputime,
pinfo['name'].strip() or '?'))
print(templ % (
user[:10],
pinfo['pid'],
pinfo['cpu_percent'],
memp,
vms,
rss,
pinfo.get('terminal', '') or '?',
ctime,
cputime,
pinfo['name'].strip() or '?'))


if __name__ == '__main__':
Expand Down
3 changes: 1 addition & 2 deletions examples/who.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
from datetime import datetime

import psutil
from psutil._compat import print_


def main():
users = psutil.users()
for user in users:
print_("%-15s %-15s %s (%s)" % (
print("%-15s %-15s %s (%s)" % (
user.name,
user.terminal or '-',
datetime.fromtimestamp(user.started).strftime("%Y-%m-%d %H:%M"),
Expand Down
3 changes: 0 additions & 3 deletions make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ rem psutil ("make.bat build", "make.bat install") and running tests
rem ("make.bat test").
rem
rem This script is modeled after my Windows installation which uses:
rem - mingw32 for Python 2.4 and 2.5
rem - Visual studio 2008 for Python 2.6, 2.7, 3.2
rem - Visual studio 2010 for Python 3.3+
rem ...therefore it might not work on your Windows installation.
Expand All @@ -17,8 +16,6 @@ rem To compile for a specific Python version run:
rem
rem set PYTHON=C:\Python24\python.exe & make.bat build
rem
rem If you compile by using mingw on Python 2.4 and 2.5 you need to patch
rem distutils first: http://stackoverflow.com/questions/13592192
rem ==========================================================================

if "%PYTHON%" == "" (
Expand Down
Loading

0 comments on commit 02d58e9

Please sign in to comment.