Kaydet (Commit) 02781dc7 authored tarafından Christian Heimes's avatar Christian Heimes

Merged revisions 61672,61674,61676-61678,61681,61683-61684 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r61672 | brett.cannon | 2008-03-20 17:13:48 +0100 (Do, 20 Mär 2008) | 2 lines

  Gave Jerry Seutter svn access for general Python development.
........
  r61674 | marc-andre.lemburg | 2008-03-20 18:31:36 +0100 (Do, 20 Mär 2008) | 7 lines

  If Mark Hammonds win32 tools are not available, try to use the _winreg module
  and sys.getwindowsversion() to get at the Windows version info.

  For the machine and processor uname() values, use the environment variables
  for these on Windows XP and later.
........
  r61676 | marc-andre.lemburg | 2008-03-20 18:55:31 +0100 (Do, 20 Mär 2008) | 5 lines

  Add documentation for updated Windows support in win32_ver().

  Add documentation for linux_distribution() API.
........
  r61677 | marc-andre.lemburg | 2008-03-20 19:08:00 +0100 (Do, 20 Mär 2008) | 2 lines

  Add news items for platform module changes.
........
  r61678 | marc-andre.lemburg | 2008-03-20 19:58:14 +0100 (Do, 20 Mär 2008) | 3 lines

  Clarfiy the availability of the extended support for win32_ver() in Py2.6.
........
  r61681 | andrew.kuchling | 2008-03-20 23:49:26 +0100 (Do, 20 Mär 2008) | 1 line

  Add lots of items
........
  r61683 | eric.smith | 2008-03-21 00:04:04 +0100 (Fr, 21 Mär 2008) | 1 line

  Fixed PEP name.
........
  r61684 | eric.smith | 2008-03-21 00:56:08 +0100 (Fr, 21 Mär 2008) | 1 line

  Comment how 'from __future__ import print_function' operates in 3.0.
........
üst 3fd13995
...@@ -187,8 +187,10 @@ Windows Platform ...@@ -187,8 +187,10 @@ Windows Platform
.. note:: .. note::
This function only works if Mark Hammond's :mod:`win32all` package is installed Note: this function works best with Mark Hammond's
and (obviously) only runs on Win32 compatible platforms. :mod:`win32all` package installed, but also on Python 2.3 and
later (support for this was added in Python 2.6). It obviously
only runs on Win32 compatible platforms.
Win95/98 specific Win95/98 specific
...@@ -222,13 +224,31 @@ Unix Platforms ...@@ -222,13 +224,31 @@ Unix Platforms
-------------- --------------
.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake')) .. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...))
Tries to determine the name of the OS distribution name Returns a tuple Tries to determine the name of the OS distribution name Returns a tuple
``(distname, version, id)`` which defaults to the args given as parameters. ``(distname, version, id)`` which defaults to the args given as parameters.
.. XXX Document linux_distribution()? ``supported_dists`` may be given to define the set of Linux
distributions to look for. It defaults to a list of currently
supported Linux distributions identified by their release file
name.
.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...), full_distribution_name=1)
Tries to determine the name of the Linux OS distribution name.
``supported_dists`` may be given to define the set of Linux
distributions to look for. It defaults to a list of currently
supported Linux distributions identified by their release file
name.
If ``full_distribution_name`` is true (default), the full
distribution read from the OS is returned. Otherwise the short name
taken from ``supported_dists`` is used.
Returns a tuple ``(distname,version,id)`` which defaults to the
args given as parameters.
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048) .. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048)
......
This diff is collapsed.
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
__copyright__ = """ __copyright__ = """
Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
Copyright (c) 2000-2007, eGenix.com Software GmbH; mailto:info@egenix.com Copyright (c) 2000-2008, eGenix.com Software GmbH; mailto:info@egenix.com
Permission to use, copy, modify, and distribute this software and its Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee or royalty is hereby granted, documentation for any purpose and without fee or royalty is hereby granted,
...@@ -525,7 +525,13 @@ def _win32_getvalue(key,name,default=''): ...@@ -525,7 +525,13 @@ def _win32_getvalue(key,name,default=''):
In case this fails, default is returned. In case this fails, default is returned.
""" """
from win32api import RegQueryValueEx try:
# Use win32api if available
from win32api import RegQueryValueEx
except ImportError:
# On Python 2.0 and later, emulate using _winreg
import _winreg
RegQueryValueEx = _winreg.QueryValueEx
try: try:
return RegQueryValueEx(key,name) return RegQueryValueEx(key,name)
except: except:
...@@ -545,9 +551,9 @@ def win32_ver(release='',version='',csd='',ptype=''): ...@@ -545,9 +551,9 @@ def win32_ver(release='',version='',csd='',ptype=''):
means the OS version uses debugging code, i.e. code that means the OS version uses debugging code, i.e. code that
checks arguments, ranges, etc. (Thomas Heller). checks arguments, ranges, etc. (Thomas Heller).
Note: this function only works if Mark Hammond's win32 Note: this function works best with Mark Hammond's win32
package is installed and obviously only runs on Win32 package installed, but also on Python 2.3 and later. It
compatible platforms. obviously only runs on Win32 compatible platforms.
""" """
# XXX Is there any way to find out the processor type on WinXX ? # XXX Is there any way to find out the processor type on WinXX ?
...@@ -561,11 +567,29 @@ def win32_ver(release='',version='',csd='',ptype=''): ...@@ -561,11 +567,29 @@ def win32_ver(release='',version='',csd='',ptype=''):
# Import the needed APIs # Import the needed APIs
try: try:
import win32api import win32api
from win32api import RegQueryValueEx, RegOpenKeyEx, \
RegCloseKey, GetVersionEx
from win32con import HKEY_LOCAL_MACHINE, VER_PLATFORM_WIN32_NT, \
VER_PLATFORM_WIN32_WINDOWS, VER_NT_WORKSTATION
except ImportError: except ImportError:
return release,version,csd,ptype # Emulate the win32api module using Python APIs
from win32api import RegQueryValueEx,RegOpenKeyEx,RegCloseKey,GetVersionEx try:
from win32con import HKEY_LOCAL_MACHINE,VER_PLATFORM_WIN32_NT,\ sys.getwindowsversion
VER_PLATFORM_WIN32_WINDOWS except AttributeError:
# No emulation possible, so return the defaults...
return release,version,csd,ptype
else:
# Emulation using _winreg (added in Python 2.0) and
# sys.getwindowsversion() (added in Python 2.3)
import _winreg
GetVersionEx = sys.getwindowsversion
RegQueryValueEx = _winreg.QueryValueEx
RegOpenKeyEx = _winreg.OpenKeyEx
RegCloseKey = _winreg.CloseKey
HKEY_LOCAL_MACHINE = _winreg.HKEY_LOCAL_MACHINE
VER_PLATFORM_WIN32_WINDOWS = 1
VER_PLATFORM_WIN32_NT = 2
VER_NT_WORKSTATION = 1
# Find out the registry key and some general version infos # Find out the registry key and some general version infos
maj,min,buildno,plat,csd = GetVersionEx() maj,min,buildno,plat,csd = GetVersionEx()
...@@ -602,11 +626,18 @@ def win32_ver(release='',version='',csd='',ptype=''): ...@@ -602,11 +626,18 @@ def win32_ver(release='',version='',csd='',ptype=''):
elif maj == 6: elif maj == 6:
if min == 0: if min == 0:
# Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx # Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx
productType = GetVersionEx(1)[8] try:
if productType == 1: # VER_NT_WORKSTATION productType = GetVersionEx(1)[8]
except TypeError:
# sys.getwindowsversion() doesn't take any arguments, so
# we cannot detect 2008 Server that way.
# XXX Add some other means of detecting 2008 Server ?!
release = 'Vista' release = 'Vista'
else: else:
release = '2008Server' if productType == VER_NT_WORKSTATION:
release = 'Vista'
else:
release = '2008Server'
else: else:
release = 'post2008Server' release = 'post2008Server'
else: else:
...@@ -617,9 +648,9 @@ def win32_ver(release='',version='',csd='',ptype=''): ...@@ -617,9 +648,9 @@ def win32_ver(release='',version='',csd='',ptype=''):
# Open the registry key # Open the registry key
try: try:
keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE,regkey) keyCurVer = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey)
# Get a value to make sure the key exists... # Get a value to make sure the key exists...
RegQueryValueEx(keyCurVer,'SystemRoot') RegQueryValueEx(keyCurVer, 'SystemRoot')
except: except:
return release,version,csd,ptype return release,version,csd,ptype
...@@ -1044,10 +1075,12 @@ def uname(): ...@@ -1044,10 +1075,12 @@ def uname():
release,version,csd,ptype = win32_ver() release,version,csd,ptype = win32_ver()
if release and version: if release and version:
use_syscmd_ver = 0 use_syscmd_ver = 0
# XXX Should try to parse the PROCESSOR_* environment variables # Try to use the PROCESSOR_* environment variables
# available on Win XP and later; see # available on Win XP and later; see
# http://support.microsoft.com/kb/888731 and # http://support.microsoft.com/kb/888731 and
# http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
# Try the 'ver' system command available on some # Try the 'ver' system command available on some
# platforms # platforms
......
"""Test correct operation of the print function. """Test correct operation of the print function.
""" """
# In 2.6, this gives us the behavior we want. In 3.0, it has
# no function, but it still must parse correctly.
from __future__ import print_function from __future__ import print_function
import unittest import unittest
......
...@@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise. ...@@ -17,6 +17,9 @@ the format to accommodate documentation needs as they arise.
Permissions History Permissions History
------------------- -------------------
- Jerry Seutter was given SVN access on 20 March 2008 by BAC, for
general contributions to Python.
- Jeff Rush was given SVN access on 18 March 2008 by AMK, for Distutils work. - Jeff Rush was given SVN access on 18 March 2008 by AMK, for Distutils work.
- David Wolever was given SVN access on 17 March 2008 by MvL, - David Wolever was given SVN access on 17 March 2008 by MvL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment