regcheck.py :  » Windows » pyExcelerator » pywin32-214 » win32 » lib » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Windows » pyExcelerator 
pyExcelerator » pywin32 214 » win32 » lib » regcheck.py
# This module is very old and useless in this day and age!  It will be
# removed in a few years (ie, 2009 or so...)

import warnings
warnings.warn("The regcheck module has been pending deprecation since build 210",
        category=PendingDeprecationWarning)

import win32con
import regutil
import win32api
import os
import sys


def CheckRegisteredExe(exename):
  try:
    os.stat(win32api.RegQueryValue(regutil.GetRootKey()  , regutil.GetAppPathsKey() + "\\" + exename))
#  except SystemError:
  except (os.error,win32api.error):
    print "Registration of %s - Not registered correctly" % exename

def CheckPathString(pathString):
  for path in pathString.split(";"):
    if not os.path.isdir(path):
      return "'%s' is not a valid directory!" % path
  return None

def CheckPythonPaths(verbose):
  if verbose: print "Python Paths:"
  # Check the core path
  if verbose: print "\tCore Path:",
  try:
    appPath = win32api.RegQueryValue(regutil.GetRootKey(), regutil.BuildDefaultPythonKey() + "\\PythonPath")
  except win32api.error, exc:
    print "** does not exist - ", exc.strerror
  problem = CheckPathString(appPath)
  if problem:
    print problem
  else:
    if verbose: print appPath
  
  key = win32api.RegOpenKey(regutil.GetRootKey(), regutil.BuildDefaultPythonKey() + "\\PythonPath", 0, win32con.KEY_READ)
  try:
    keyNo = 0
    while 1:
      try:
        appName = win32api.RegEnumKey(key, keyNo)
        appPath = win32api.RegQueryValue(key, appName)
        if verbose: print "\t"+appName+":",
        if appPath:
          problem = CheckPathString(appPath)
          if problem:
            print problem
          else:
            if verbose: print appPath
        else:
          if verbose: print "(empty)"
        keyNo = keyNo + 1
      except win32api.error:
        break
  finally:
    win32api.RegCloseKey(key)

def CheckHelpFiles(verbose):
  if verbose: print "Help Files:"
  try:
    key = win32api.RegOpenKey(regutil.GetRootKey(), regutil.BuildDefaultPythonKey() + "\\Help", 0, win32con.KEY_READ)
  except win32api.error, exc:
    import winerror
    if exc.winerror!=winerror.ERROR_FILE_NOT_FOUND:
      raise
    return
    
  try:
    keyNo = 0
    while 1:
      try:
        helpDesc = win32api.RegEnumKey(key, keyNo)
        helpFile = win32api.RegQueryValue(key, helpDesc)
        if verbose: print "\t"+helpDesc+":",
        # query the os section.
        try:
          os.stat(helpFile )
          if verbose: print helpFile
        except os.error:
          print "** Help file %s does not exist" % helpFile
        keyNo = keyNo + 1
      except win32api.error, exc:
        import winerror
        if exc.winerror!=winerror.ERROR_NO_MORE_ITEMS:
          raise
        break
  finally:
    win32api.RegCloseKey(key)

def CheckRegisteredModules(verbose):
  # Check out all registered modules.
  k=regutil.BuildDefaultPythonKey() + "\\Modules"
  try:
    keyhandle = win32api.RegOpenKey(regutil.GetRootKey(), k)
    print "WARNING: 'Modules' registry entry is deprectated and evil!"
  except win32api.error, exc:
    import winerror
    if exc.winerror!=winerror.ERROR_FILE_NOT_FOUND:
      raise
    return

def CheckRegistry(verbose=0):
  # check the registered modules
  if verbose and 'pythonpath' in os.environ:
    print "Warning - PythonPath in environment - please check it!"
  # Check out all paths on sys.path
  
  CheckPythonPaths(verbose)
  CheckHelpFiles(verbose)
  CheckRegisteredModules(verbose)
  CheckRegisteredExe("Python.exe")

if __name__=='__main__':
  if len(sys.argv)>1 and sys.argv[1]=='-q':
    verbose = 0
  else:
    verbose = 1
  CheckRegistry(verbose)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.