home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_2571 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  3.3 KB  |  102 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import win32api
  5. import _winreg
  6. import sys
  7. import shutil
  8. import os
  9.  
  10. def usage_and_die(rc):
  11.     print 
  12.     print 'This script is designed to copy and register the Python debug'
  13.     print 'binaries.  It looks for pythonxx_d.dll, pythoncomxx_d.dll etc,'
  14.     print 'and installs them to work correctly with Python debug builds.'
  15.     print 
  16.     print 'You will generally find this script in the. zip file that'
  17.     print 'included these _d files.  Please run this script from'
  18.     print 'that directory'
  19.     sys.exit(rc)
  20.  
  21. if win32api.__file__.find('_d') > 0:
  22.     print 'This scripts appears to be running a DEBUG version of Python.'
  23.     print 'Please run it using a normal release build (python.exe)'
  24.     usage_and_die(1)
  25.  
  26.  
  27. try:
  28.     import pythoncom
  29. except ImportError:
  30.     details = None
  31.     print 'Could not import the release version of pythoncom'
  32.     print 'The error details are: %s' % (details,)
  33.     print 'Please correct this error and rerun the script'
  34.     usage_and_die(2)
  35.  
  36.  
  37. try:
  38.     import pywintypes
  39. except ImportError:
  40.     details = None
  41.     print 'Could not import the release version of pywintypes'
  42.     print 'The error details are: %s' % (details,)
  43.     print 'Please correct this error and rerun the script'
  44.     usage_and_die(2)
  45.  
  46.  
  47. def _docopy(src, dest):
  48.     orig_src = src
  49.     if not os.path.isfile(src):
  50.         src = os.path.join(os.path.split(sys.argv[0])[0], src)
  51.         print 'Can not find %s or %s to copy' % (os.path.abspath(orig_src), os.path.abspath(src))
  52.         return 0
  53.     
  54.     try:
  55.         shutil.copy(src, dest)
  56.         print 'Copied %s -> %s' % (src, dest)
  57.         return 1
  58.     except:
  59.         os.path.isfile(src)
  60.         print "Error copying '%s' -> '%s'" % (src, dest)
  61.         print str(sys.exc_info[1])
  62.         usage_and_die(3)
  63.  
  64.  
  65.  
  66. def _doregister(mod_name, dll_name):
  67.     
  68.     try:
  69.         key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Python\\PythonCore\\%s\\Modules\\%s' % (sys.winver, mod_name))
  70.     except _winreg.error:
  71.         
  72.         try:
  73.             key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'Software\\Python\\PythonCore\\%s\\Modules\\%s' % (sys.winver, mod_name))
  74.         except _winreg.error:
  75.             print "Could not find the existing '%s' module registered in the registry" % (mod_name,)
  76.             usage_and_die(4)
  77.         except:
  78.             None<EXCEPTION MATCH>_winreg.error
  79.         
  80.  
  81.         None<EXCEPTION MATCH>_winreg.error
  82.  
  83.     sub_key = _winreg.CreateKey(key, 'Debug')
  84.     _winreg.SetValue(sub_key, None, _winreg.REG_SZ, dll_name)
  85.     print "Registered '%s' in the registry" % (dll_name,)
  86.  
  87.  
  88. def _domodule(mod_name, release_mod_filename):
  89.     (path, fname) = os.path.split(release_mod_filename)
  90.     (base, ext) = os.path.splitext(fname)
  91.     new_fname = base + '_d' + ext
  92.     if _docopy(new_fname, path):
  93.         _doregister(mod_name, os.path.abspath(os.path.join(path, new_fname)))
  94.     
  95.  
  96. (path, fname) = (path, fname) = os.path.split(win32api.GetModuleFileName(sys.dllhandle))
  97. (base, ext) = os.path.splitext(fname)
  98. _docopy(base + '_d' + ext, path)
  99. _domodule('pythoncom', pythoncom.__file__)
  100. _domodule('pywintypes', pywintypes.__file__)
  101. print 'System _d files were setup.'
  102.