[pywin32-checkins] pywin32 pywin32_postinstall.py,1.25,1.25.2.1
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-10-01 14:01:22
|
Update of /cvsroot/pywin32/pywin32 In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv9128 Modified Files: Tag: py3k pywin32_postinstall.py Log Message: Make 2.x and 3.x compatible Index: pywin32_postinstall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/pywin32_postinstall.py,v retrieving revision 1.25 retrieving revision 1.25.2.1 diff -C2 -d -r1.25 -r1.25.2.1 *** pywin32_postinstall.py 30 May 2008 23:11:35 -0000 1.25 --- pywin32_postinstall.py 1 Oct 2008 14:01:15 -0000 1.25.2.1 *************** *** 4,8 **** # and creates a pth file import os, sys, glob, shutil, time ! import _winreg # Send output somewhere so it can be found if necessary... --- 4,11 ---- # and creates a pth file import os, sys, glob, shutil, time ! try: ! import _winreg as winreg ! except ImportError: ! import winreg # Send output somewhere so it can be found if necessary... *************** *** 52,62 **** def get_root_hkey(): try: ! _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, ! root_key_name, _winreg.KEY_CREATE_SUB_KEY) ! return _winreg.HKEY_LOCAL_MACHINE except OSError, details: # Either not exist, or no permissions to create subkey means # must be HKCU ! return _winreg.HKEY_CURRENT_USER try: --- 55,65 ---- def get_root_hkey(): try: ! winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, ! root_key_name, winreg.KEY_CREATE_SUB_KEY) ! return winreg.HKEY_LOCAL_MACHINE except OSError, details: # Either not exist, or no permissions to create subkey means # must be HKCU ! return winreg.HKEY_CURRENT_USER try: *************** *** 108,122 **** return except win32api.error, details: ! if details[0]==5: # access denied - user not admin. raise if silent: # Running silent mode - just re-raise the error. raise - err_msg = details[2] tb = None full_desc = "Error %s\n\n" \ "If you have any Python applications running, " \ "please close them now\nand select 'Retry'\n\n%s" \ ! % (desc, err_msg) rc = win32api.MessageBox(0, full_desc, --- 111,124 ---- return except win32api.error, details: ! if details.winerror==5: # access denied - user not admin. raise if silent: # Running silent mode - just re-raise the error. raise tb = None full_desc = "Error %s\n\n" \ "If you have any Python applications running, " \ "please close them now\nand select 'Retry'\n\n%s" \ ! % (desc, details.strerror) rc = win32api.MessageBox(0, full_desc, *************** *** 153,161 **** def SetPyKeyVal(key_name, value_name, value): root_hkey = get_root_hkey() ! root_key = _winreg.OpenKey(root_hkey, root_key_name) try: ! my_key = _winreg.CreateKey(root_key, key_name) try: ! _winreg.SetValueEx(my_key, value_name, 0, _winreg.REG_SZ, value) finally: my_key.Close() --- 155,163 ---- def SetPyKeyVal(key_name, value_name, value): root_hkey = get_root_hkey() ! root_key = winreg.OpenKey(root_hkey, root_key_name) try: ! my_key = winreg.CreateKey(root_key, key_name) try: ! winreg.SetValueEx(my_key, value_name, 0, winreg.REG_SZ, value) finally: my_key.Close() *************** *** 188,192 **** like file_created to add registry entries to uninstall log ??? """ ! import _winreg, os, distutils.sysconfig lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1) --- 190,194 ---- like file_created to add registry entries to uninstall log ??? """ ! import os, distutils.sysconfig lib_dir = distutils.sysconfig.get_python_lib(plat_specific=1) *************** *** 205,221 **** if register: for key, sub_key, val in keys_vals: ! ## Since _winreg only uses the character Api functions, this can fail if Python ## is installed to a path containing non-ascii characters ! hkey = _winreg.CreateKey(classes_root, key) if sub_key: ! hkey = _winreg.CreateKey(hkey, sub_key) ! _winreg.SetValueEx(hkey, None, 0, _winreg.REG_SZ, val) hkey.Close() else: for key, sub_key, val in keys_vals: try: ! _winreg.DeleteKey(classes_root, key) except OSError, why: ! if why.errno != 2: # file not found raise finally: --- 207,224 ---- if register: for key, sub_key, val in keys_vals: ! ## Since winreg only uses the character Api functions, this can fail if Python ## is installed to a path containing non-ascii characters ! hkey = winreg.CreateKey(classes_root, key) if sub_key: ! hkey = winreg.CreateKey(hkey, sub_key) ! winreg.SetValueEx(hkey, None, 0, winreg.REG_SZ, val) hkey.Close() else: for key, sub_key, val in keys_vals: try: ! winreg.DeleteKey(classes_root, key) except OSError, why: ! winerror = getattr(why, 'winerror', why.errno) ! if winerror != 2: # file not found raise finally: *************** *** 225,229 **** def get_shortcuts_folder(): ! if get_root_hkey()==_winreg.HKEY_LOCAL_MACHINE: try: fldr = get_special_folder_path("CSIDL_COMMON_PROGRAMS") --- 228,232 ---- def get_shortcuts_folder(): ! if get_root_hkey()==winreg.HKEY_LOCAL_MACHINE: try: fldr = get_special_folder_path("CSIDL_COMMON_PROGRAMS") *************** *** 236,240 **** try: ! install_group = _winreg.QueryValue(get_root_hkey(), root_key_name + "\\InstallPath\\InstallGroup") except OSError: --- 239,243 ---- try: ! install_group = winreg.QueryValue(get_root_hkey(), root_key_name + "\\InstallPath\\InstallGroup") except OSError: *************** *** 256,262 **** return shell.SHGetSpecialFolderPath(0,shellcon.CSIDL_SYSTEM) except (pythoncom.com_error, win32process.error): ! return win32api.GetSystemDirectory().encode('mbcs') except ImportError: ! return win32api.GetSystemDirectory().encode('mbcs') def install(): --- 259,265 ---- return shell.SHGetSpecialFolderPath(0,shellcon.CSIDL_SYSTEM) except (pythoncom.com_error, win32process.error): ! return win32api.GetSystemDirectory() except ImportError: ! return win32api.GetSystemDirectory() def install(): *************** *** 278,288 **** for name in "pythoncom pywintypes".split(): keyname = "Software\\Python\\PythonCore\\" + sys.winver + "\\Modules\\" + name ! for root in _winreg.HKEY_LOCAL_MACHINE, _winreg.HKEY_CURRENT_USER: try: ! _winreg.DeleteKey(root, keyname + "\\Debug") except WindowsError: pass try: ! _winreg.DeleteKey(root, keyname) except WindowsError: pass --- 281,291 ---- for name in "pythoncom pywintypes".split(): keyname = "Software\\Python\\PythonCore\\" + sys.winver + "\\Modules\\" + name ! for root in winreg.HKEY_LOCAL_MACHINE, winreg.HKEY_CURRENT_USER: try: ! winreg.DeleteKey(root, keyname + "\\Debug") except WindowsError: pass try: ! winreg.DeleteKey(root, keyname) except WindowsError: pass *************** *** 320,324 **** break except win32api.error, details: ! if details[0]==5: # access denied - user not admin - try sys.prefix dir, # but first check that a version doesn't already exist --- 323,327 ---- break except win32api.error, details: ! if details.winerror==5: # access denied - user not admin - try sys.prefix dir, # but first check that a version doesn't already exist *************** *** 357,361 **** # There may be no main Python key in HKCU if, eg, an admin installed # python itself. ! _winreg.CreateKey(get_root_hkey(), root_key_name) # Register the .chm help file. --- 360,364 ---- # There may be no main Python key in HKCU if, eg, an admin installed # python itself. ! winreg.CreateKey(get_root_hkey(), root_key_name) # Register the .chm help file. |