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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import warnings
  5. warnings.warn('The regcheck module has been pending deprecation since build 210', category = PendingDeprecationWarning)
  6. import win32con
  7. import regutil
  8. import win32api
  9. import os
  10. import sys
  11.  
  12. def CheckRegisteredExe(exename):
  13.     
  14.     try:
  15.         os.stat(win32api.RegQueryValue(regutil.GetRootKey(), regutil.GetAppPathsKey() + '\\' + exename))
  16.     except (os.error, win32api.error):
  17.         print 'Registration of %s - Not registered correctly' % exename
  18.  
  19.  
  20.  
  21. def CheckPathString(pathString):
  22.     import string
  23.     for path in string.split(pathString, ';'):
  24.         if not os.path.isdir(path):
  25.             return "'%s' is not a valid directory!" % path
  26.     
  27.  
  28.  
  29. def CheckPythonPaths(verbose):
  30.     if verbose:
  31.         print 'Python Paths:'
  32.     
  33.     if verbose:
  34.         print '\tCore Path:',
  35.     
  36.     
  37.     try:
  38.         appPath = win32api.RegQueryValue(regutil.GetRootKey(), regutil.BuildDefaultPythonKey() + '\\PythonPath')
  39.     except win32api.error:
  40.         (code, fn, desc) = None
  41.         print '** does not exist - ', desc
  42.  
  43.     problem = CheckPathString(appPath)
  44.     if problem:
  45.         print problem
  46.     elif verbose:
  47.         print appPath
  48.     
  49.     key = win32api.RegOpenKey(regutil.GetRootKey(), regutil.BuildDefaultPythonKey() + '\\PythonPath', 0, win32con.KEY_READ)
  50.     
  51.     try:
  52.         keyNo = 0
  53.         while None:
  54.             
  55.             try:
  56.                 appName = win32api.RegEnumKey(key, keyNo)
  57.                 appPath = win32api.RegQueryValue(key, appName)
  58.                 if verbose:
  59.                     print '\t' + appName + ':',
  60.                 
  61.                 if appPath:
  62.                     problem = CheckPathString(appPath)
  63.                     if problem:
  64.                         print problem
  65.                     elif verbose:
  66.                         print appPath
  67.                     
  68.                 elif verbose:
  69.                     print '(empty)'
  70.                 
  71.                 keyNo = keyNo + 1
  72.             continue
  73.             except win32api.error:
  74.                 break
  75.                 continue
  76.             
  77.  
  78.         win32api.RegCloseKey(key)
  79.         return None
  80.  
  81.  
  82.  
  83. def CheckHelpFiles(verbose):
  84.     if verbose:
  85.         print 'Help Files:'
  86.     
  87.     
  88.     try:
  89.         key = win32api.RegOpenKey(regutil.GetRootKey(), regutil.BuildDefaultPythonKey() + '\\Help', 0, win32con.KEY_READ)
  90.     except win32api.error:
  91.         (code, fn, details) = None
  92.         import winerror
  93.         if code != winerror.ERROR_FILE_NOT_FOUND:
  94.             raise win32api.error, (code, fn, details)
  95.         code != winerror.ERROR_FILE_NOT_FOUND
  96.         return None
  97.  
  98.     
  99.     try:
  100.         keyNo = 0
  101.         while None:
  102.             
  103.             try:
  104.                 helpDesc = win32api.RegEnumKey(key, keyNo)
  105.                 helpFile = win32api.RegQueryValue(key, helpDesc)
  106.                 if verbose:
  107.                     print '\t' + helpDesc + ':',
  108.                 
  109.                 
  110.                 try:
  111.                     os.stat(helpFile)
  112.                     if verbose:
  113.                         print helpFile
  114.                 except os.error:
  115.                     print '** Help file %s does not exist' % helpFile
  116.  
  117.                 keyNo = keyNo + 1
  118.             continue
  119.             except win32api.error:
  120.                 (code, fn, desc) = None
  121.                 import winerror
  122.                 if code != winerror.ERROR_NO_MORE_ITEMS:
  123.                     raise win32api.error, (code, fn, desc)
  124.                 code != winerror.ERROR_NO_MORE_ITEMS
  125.                 break
  126.                 continue
  127.             
  128.  
  129.         win32api.RegCloseKey(key)
  130.         return None
  131.  
  132.  
  133.  
  134. def CheckRegisteredModules(verbose):
  135.     k = regutil.BuildDefaultPythonKey() + '\\Modules'
  136.     
  137.     try:
  138.         keyhandle = win32api.RegOpenKey(regutil.GetRootKey(), k)
  139.         print "WARNING: 'Modules' registry entry is deprectated and evil!"
  140.     except win32api.error:
  141.         (code, fn, details) = None
  142.         import winerror
  143.         if code != winerror.ERROR_FILE_NOT_FOUND:
  144.             raise win32api.error, (code, fn, details)
  145.         code != winerror.ERROR_FILE_NOT_FOUND
  146.         return None
  147.  
  148.  
  149.  
  150. def CheckRegistry(verbose = 0):
  151.     if verbose and os.environ.has_key('pythonpath'):
  152.         print 'Warning - PythonPath in environment - please check it!'
  153.     
  154.     CheckPythonPaths(verbose)
  155.     CheckHelpFiles(verbose)
  156.     CheckRegisteredModules(verbose)
  157.     CheckRegisteredExe('Python.exe')
  158.  
  159. if __name__ == '__main__':
  160.     if len(sys.argv) > 1 and sys.argv[1] == '-q':
  161.         verbose = 0
  162.     else:
  163.         verbose = 1
  164.     CheckRegistry(verbose)
  165.  
  166.