home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-python-addon-1.4.9-installer.exe / win32_postinstall.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2004-10-01  |  5.5 KB  |  99 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.3)
  3.  
  4. import sys
  5. import os
  6. import shutil
  7. import distutils.sysconfig as distutils
  8.  
  9. def getApacheDirOptions():
  10.     '''find potential apache directories in the registry...'''
  11.     
  12.     try:
  13.         import win32api
  14.         import win32con
  15.         
  16.         class regkey:
  17.             '''simple wrapper for registry functions that closes keys nicely...'''
  18.             
  19.             def __init__(self, parent, subkeyname):
  20.                 self.key = win32api.RegOpenKey(parent, subkeyname)
  21.  
  22.             
  23.             def childkey(self, subkeyname):
  24.                 return regkey(self.key, subkeyname)
  25.  
  26.             
  27.             def subkeynames(self):
  28.                 numsubkeys = win32api.RegQueryInfoKey(self.key)[0]
  29.                 return [ win32api.RegEnumKey(self.key, index) for index in range(numsubkeys) ]
  30.  
  31.             
  32.             def getvalue(self, valuename):
  33.                 return win32api.RegQueryValueEx(self.key, valuename)
  34.  
  35.             
  36.             def __del__(self):
  37.                 win32api.RegCloseKey(self.key)
  38.  
  39.  
  40.     except ImportError:
  41.         return { }
  42.  
  43.     versions = { }
  44.     apachekey = regkey(win32con.HKEY_LOCAL_MACHINE, 'Software').childkey('Apache Group').childkey('Apache')
  45.     for versionname in apachekey.subkeynames():
  46.         serverroot = apachekey.childkey(versionname).getvalue('ServerRoot')
  47.         versions[versionname] = serverroot[0]
  48.     
  49.     return versions
  50.  
  51.  
  52. def askForApacheDir(apachediroptions):
  53.     if len(apachediroptions) > 0:
  54.         versionnames = apachediroptions.keys()
  55.         versionnames.sort()
  56.         initialdir = apachediroptions[versionnames[-1]]
  57.     else:
  58.         initialdir = 'C:/Program Files/Apache Group/Apache2'
  59.     
  60.     try:
  61.         askdirectory = askdirectory
  62.         import tkFileDialog
  63.         Tk = Tk
  64.         import Tkinter
  65.         root = Tk()
  66.         root.withdraw()
  67.         path = askdirectory(title = 'Where is Apache installed?', initialdir = initialdir, mustexist = 1, master = root)
  68.         root.quit()
  69.         root.destroy()
  70.         return path
  71.     except ImportError:
  72.         
  73.         try:
  74.             shell = shell
  75.             import win32com.shell
  76.             (pidl, displayname, imagelist) = shell.SHBrowseForFolder(0, None, 'Where is Apache installed?')
  77.             path = shell.SHGetPathFromIDList(pidl)
  78.             return path
  79.         except ImportError:
  80.             return ''
  81.         except:
  82.             None<EXCEPTION MATCH>ImportError
  83.         
  84.  
  85.         None<EXCEPTION MATCH>ImportError
  86.  
  87.  
  88. if len(sys.argv) == 0 or sys.argv[1] != '-remove':
  89.     mp = os.path.join(distutils.sysconfig.get_python_lib(), 'mod_python_so.pyd')
  90.     apachediroptions = getApacheDirOptions()
  91.     apachedir = askForApacheDir(apachediroptions)
  92.     if apachedir:
  93.         shutil.copy2(mp, os.path.join(apachedir, 'modules', 'mod_python.so'))
  94.         os.remove(mp)
  95.         print 'Important Note for Windows users, PLEASE READ!!!\n\n        1. This script does not attempt to modify Apache configuration,\n           you must do it manually:\n\n           Edit %s,\n           find where other LoadModule lines are and add this:\n                LoadModule python_module modules/mod_python.so\n\n        2. Now test your installation using the instructions at this link:\n           http://www.modpython.org/live/current/doc-html/inst-testing.html\n\n        ' % os.path.join(apachedir, 'conf', 'httpd.conf')
  96.     else:
  97.         print 'Important Note for Windows users, PLEASE READ!!!\n\n        1. It appears that you do not have Tkinter installed,\n           which is required for a part of this installation.\n           Therefore you must manually take\n           "%s"\n           and copy it to your Apache modules directory.\n\n        2. This script does not attempt to modify Apache configuration,\n           you must do it manually:\n\n           Edit %s,\n           find where other LoadModule lines and add this:\n                LoadModule python_module modules/mod_python.so\n\n        3. Now test your installation using the instructions at this link:\n           http://www.modpython.org/live/current/doc-html/inst-testing.html\n\n        ' % (mp, os.path.join(apachedir, 'conf', 'httpd.conf'))
  98.  
  99.