mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Merged revisions 80859 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
  r80859 | brian.curtin | 2010-05-05 22:05:50 -0500 (Wed, 05 May 2010) | 12 lines
  Merged revisions 80857 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk
  ........
    r80857 | brian.curtin | 2010-05-05 21:54:44 -0500 (Wed, 05 May 2010) | 5 lines
    Fix #7863. Properly identify Windows 7 and Server 2008 R2.
    Removed various unused code and added a way to correctly determine
    server vs. workstation via the registry.
  ........
................
			
			
This commit is contained in:
		
							parent
							
								
									f870d8736a
								
							
						
					
					
						commit
						e7837354cd
					
				
					 1 changed files with 34 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -576,10 +576,17 @@ def win32_ver(release='',version='',csd='',ptype=''):
 | 
			
		|||
            VER_PLATFORM_WIN32_WINDOWS = 1
 | 
			
		||||
            VER_PLATFORM_WIN32_NT = 2
 | 
			
		||||
            VER_NT_WORKSTATION = 1
 | 
			
		||||
            VER_NT_SERVER = 3
 | 
			
		||||
            REG_SZ = 1
 | 
			
		||||
 | 
			
		||||
    # Find out the registry key and some general version infos
 | 
			
		||||
    maj,min,buildno,plat,csd = GetVersionEx()
 | 
			
		||||
    winver = GetVersionEx()
 | 
			
		||||
    maj,min,buildno,plat,csd = winver
 | 
			
		||||
    version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF)
 | 
			
		||||
    if hasattr(winver, "service_pack"):
 | 
			
		||||
        if winver.service_pack != "":
 | 
			
		||||
            csd = 'SP%s' % winver.service_pack_major
 | 
			
		||||
    else:
 | 
			
		||||
        if csd[:13] == 'Service Pack ':
 | 
			
		||||
            csd = 'SP' + csd[13:]
 | 
			
		||||
    if plat == VER_PLATFORM_WIN32_WINDOWS:
 | 
			
		||||
| 
						 | 
				
			
			@ -610,20 +617,33 @@ def win32_ver(release='',version='',csd='',ptype=''):
 | 
			
		|||
            else:
 | 
			
		||||
                release = 'post2003'
 | 
			
		||||
        elif maj == 6:
 | 
			
		||||
            if min == 0:
 | 
			
		||||
                # Per http://msdn2.microsoft.com/en-us/library/ms724429.aspx
 | 
			
		||||
                try:
 | 
			
		||||
                    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'
 | 
			
		||||
            if hasattr(winver, "product_type"):
 | 
			
		||||
                product_type = winver.product_type
 | 
			
		||||
            else:
 | 
			
		||||
                    if productType == VER_NT_WORKSTATION:
 | 
			
		||||
                product_type = VER_NT_WORKSTATION
 | 
			
		||||
                # Without an OSVERSIONINFOEX capable sys.getwindowsversion(),
 | 
			
		||||
                # or help from the registry, we cannot properly identify
 | 
			
		||||
                # non-workstation versions.
 | 
			
		||||
                try:
 | 
			
		||||
                    key = RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey)
 | 
			
		||||
                    name, type = RegQueryValueEx(key, "ProductName")
 | 
			
		||||
                    # Discard any type that isn't REG_SZ
 | 
			
		||||
                    if type == REG_SZ and name.find("Server") != -1:
 | 
			
		||||
                        product_type = VER_NT_SERVER
 | 
			
		||||
                except WindowsError:
 | 
			
		||||
                    # Use default of VER_NT_WORKSTATION
 | 
			
		||||
                    pass
 | 
			
		||||
 | 
			
		||||
            if min == 0:
 | 
			
		||||
                if product_type == VER_NT_WORKSTATION:
 | 
			
		||||
                    release = 'Vista'
 | 
			
		||||
                else:
 | 
			
		||||
                    release = '2008Server'
 | 
			
		||||
            elif min == 1:
 | 
			
		||||
                if product_type == VER_NT_WORKSTATION:
 | 
			
		||||
                    release = '7'
 | 
			
		||||
                else:
 | 
			
		||||
                    release = '2008ServerR2'
 | 
			
		||||
            else:
 | 
			
		||||
                release = 'post2008Server'
 | 
			
		||||
    else:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue