testHost4Dbg.py :  » Windows » pyExcelerator » pywin32-214 » com » win32comext » AXScript » test » 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 » com » win32comext » AXScript » test » testHost4Dbg.py
import os, sys, traceback
from win32com.axscript import axscript
from win32com.axscript.server import axsite
from win32com.axscript.server.error import Exception
import pythoncom
from win32com.server import util
import win32ui

version = "0.0.1"

class MySite(axsite.AXSite):

  def OnScriptError(self, error):
    print "An error occurred in the Script Code"
    exc = error.GetExceptionInfo()
    try:
      text = error.GetSourceLineText()
    except:
      text = "<unknown>"
    context, line, char = error.GetSourcePosition()
    print "Exception: %s (line %d)\n%s\n%s^\n%s" % (exc[1], line, text, " " * (char-1), exc[2])

class ObjectModel:
  _public_methods_ = [ 'echo', 'msgbox' ]
  def echo(self, *args):
    print ''.join(map(str, args))
  def msgbox(self, *args):
    msg = ''.join(map(str, args))
    win32ui.MessageBox(msg)

def TestEngine():
  model = {'Test' : util.wrap(ObjectModel()) }
  scriptDir = "."
  site = MySite(model)
  pyEngine = site._AddEngine("Python")
#  pyEngine2 = site._AddEngine("Python")
  vbEngine = site._AddEngine("VBScript")
#  forthEngine = site._AddEngine("ForthScript")
  try:
#    code = open(os.path.join(scriptDir, "debugTest.4ths"),"rb").read()
#    forthEngine.AddCode(code)
    code = open(os.path.join(scriptDir, "debugTest.pys"),"rb").read()
    pyEngine.AddCode(code)
    code = open(os.path.join(scriptDir, "debugTest.vbs"),"rb").read()
    vbEngine.AddCode(code)
#    code = open(os.path.join(scriptDir, "debugTestFail.pys"),"rb").read()
#    pyEngine2.AddCode(code)

#    from win32com.axdebug import axdebug
#    sessionProvider=pythoncom.CoCreateInstance(axdebug.CLSID_DefaultDebugSessionProvider,None,pythoncom.CLSCTX_ALL, axdebug.IID_IDebugSessionProvider)
#    sessionProvider.StartDebugSession(None)
    
    raw_input("Press enter to continue")
 #   forthEngine.Start()
    pyEngine.Start() # Actually run the Python code
    vbEngine.Start() # Actually run the VB code
  except pythoncom.com_error, details:
    print "Script failed: %s (0x%x)" % (details[1], details[0])
  # Now run the code expected to fail!
#  try:
#    pyEngine2.Start() # Actually run the Python code that fails!
#    print "Script code worked when it should have failed."
#  except pythoncom.com_error:
#    pass

  site._Close()

if __name__ == '__main__':
  import win32com.axdebug.util
  try:
    TestEngine()
  except:
    traceback.print_exc()
  win32com.axdebug.util._dump_wrapped()
  sys.exc_type = sys.exc_value = sys.exc_traceback = None
  print pythoncom._GetInterfaceCount(),"com objects still alive"
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.