home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CMCD0704.ISO / Software / Shareware / Comunicatii / jyte / jyte.exe / pydumper.py < prev    next >
Text File  |  1999-09-02  |  2KB  |  71 lines

  1. # pydumper.py
  2. #
  3. # This is being worked on - it does not yet work at all, in ay way
  4. # shape or form :-)
  5. #
  6. # A new script engine, derived from the standard scripting engine,
  7. # which dumps information.
  8.  
  9. # This generally can be used to grab all sorts of useful details about
  10. # an engine - expose bugs in it or Python, dump the object model, etc.
  11.  
  12. # As it is derived from the standard engine, it fully supports Python
  13. # as a scripting language - meaning the dumps produced can be quite dynamic,
  14. # and based on the script code you execute.
  15.  
  16. import pyscript
  17. from win32com.axscript import axscript
  18.  
  19. from pyscript import RaiseAssert, trace, Exception, SCRIPTTEXT_FORCEEXECUTION
  20.  
  21. PyDump_CLSID = '{ac527e60-c693-11d0-9c25-00aa00125a98}'
  22.  
  23. class AXScriptAttribute(pyscript.AXScriptAttribute):
  24.     pass
  25.  
  26. class NamedScriptAttribute(pyscript.NamedScriptAttribute):
  27.     pass
  28.  
  29.  
  30. class PyScript(pyscript.PyScript):
  31.     pass
  32.  
  33.  
  34. def Register():
  35.     import sys
  36.     if '-d' in sys.argv:
  37.         dispatcher = "DispatcherWin32trace"
  38.         debug_desc = " ("+dispatcher+")"
  39.         debug_option = "Yes"
  40.     else:
  41.         dispatcher = None
  42.         debug_desc = ""
  43.         debug_option = ""
  44.  
  45.     categories = [axscript.CATID_ActiveScript,axscript.CATID_ActiveScriptParse]
  46.     clsid = PyDump_CLSID
  47.     lcid = 0x0409 # // english
  48.     policy = None # "win32com.axscript.client.axspolicy.AXScriptPolicy"
  49.  
  50.     print "Registering COM server%s..." % debug_desc
  51.     from win32com.server.register import RegisterServer
  52.  
  53.     languageName = "PyDump"
  54.     verProgId = "Python.Dumper.1"
  55.     RegisterServer(clsid = clsid, pythonInstString = "win32com.axscript.client.pyscript.PyDumper", 
  56.                        className = "Python Debugging/Dumping ActiveX Scripting Engine",
  57.                        progID = languageName, verProgID = verProgId,
  58.                        catids = categories, 
  59.                        policy=policy, dispatcher = dispatcher)
  60.  
  61.     CreateRegKey(languageName + "\\OLEScript")
  62.     # Basic Registration for wsh.
  63.     win32com.server.register._set_string(".pysDump", "pysDumpFile")
  64.     win32com.server.register._set_string("pysDumpFile\\ScriptEngine", languageName)
  65.     print "Dumping Server registered."
  66.     
  67. if __name__=='__main__':
  68.     Register()
  69.  
  70.  
  71.