本文整理汇总了Python中win32com.server.util.wrap函数的典型用法代码示例。如果您正苦于以下问题:Python wrap函数的具体用法?Python wrap怎么用?Python wrap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wrap函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testLogger
def testLogger():
assert not hasattr(win32com, "logger")
handler = TestLogHandler()
formatter = logging.Formatter('%(message)s')
handler.setFormatter(formatter)
log = logging.getLogger("win32com_test")
log.addHandler(handler)
win32com.logger = log
# Now throw some exceptions!
# Native interfaces
com_server = wrap(TestServer(), pythoncom.IID_IStream)
try:
com_server.Commit(0)
raise RuntimeError("should have failed")
except pythoncom.error:
pass
assert handler.num_emits == 1, handler.num_emits
handler.num_emits = 0 # reset
com_server = Dispatch(wrap(TestServer()))
try:
com_server.Commit(0)
raise RuntimeError("should have failed")
except pythoncom.error:
pass
assert handler.num_emits == 1, handler.num_emits
开发者ID:AT-GROUP,项目名称:AT-PLANNER,代码行数:26,代码来源:errorSemantics.py
示例2: test
def test():
bag = Bag()
target = Target()
log = Log()
target.Save(bag, 1, 1)
target.Load(bag, log)
comBag = util.wrap(bag, pythoncom.IID_IPropertyBag)
comTarget = util.wrap(target, pythoncom.IID_IPersistPropertyBag)
comLog = util.wrap(log, pythoncom.IID_IErrorLog)
comTarget.Save(comBag, 1, 1)
comTarget.Load(comBag, comLog)
开发者ID:hkfr,项目名称:data,代码行数:14,代码来源:trybag.py
示例3: __init__
def __init__(self):
message_map = {
win32con.WM_DESTROY: self.OnDestroy,
win32con.WM_COMMAND: self.OnCommand,
win32con.WM_SIZE: self.OnSize,
}
# Register the Window class.
wc = win32gui.WNDCLASS()
hinst = wc.hInstance = win32api.GetModuleHandle(None)
wc.lpszClassName = "test_explorer_browser"
wc.lpfnWndProc = message_map # could also specify a wndproc.
classAtom = win32gui.RegisterClass(wc)
# Create the Window.
style = win32con.WS_OVERLAPPEDWINDOW | win32con.WS_VISIBLE
self.hwnd = win32gui.CreateWindow( classAtom, "Python IExplorerBrowser demo", style, \
0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, \
0, 0, hinst, None)
eb = pythoncom.CoCreateInstance(shellcon.CLSID_ExplorerBrowser, None, pythoncom.CLSCTX_ALL, shell.IID_IExplorerBrowser)
# as per MSDN docs, hook up events early
self.event_cookie = eb.Advise(wrap(EventHandler()))
eb.SetOptions(shellcon.EBO_SHOWFRAMES)
rect = win32gui.GetClientRect(self.hwnd)
# Set the flags such that the folders autoarrange and non web view is presented
flags = (shellcon.FVM_LIST, shellcon.FWF_AUTOARRANGE | shellcon.FWF_NOWEBVIEW)
eb.Initialize(self.hwnd, rect, (0, shellcon.FVM_DETAILS))
# And start browsing at the root of the namespace.
eb.BrowseToIDList([], shellcon.SBSP_ABSOLUTE)
#eb.FillFromObject(None, shellcon.EBF_NODROPTARGET);
#eb.SetEmptyText("No known folders yet...");
self.eb = eb
开发者ID:CoDEmanX,项目名称:ArangoDB,代码行数:31,代码来源:explorer_browser.py
示例4: TestEngine
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])
开发者ID:hkfr,项目名称:data,代码行数:28,代码来源:testHost4Dbg.py
示例5: getSite
def getSite(self, code = None, fam = None, user = None):
os.chdir(pywikipediaDir)
site = wikipedia.getSite(code, fam, user)
site.objectVer = wikipedia.__version__
site.objectName = "WikiSite"
site._public_methods_ = ['__cmp__', '__repr__', 'allmessages_address', 'allpages', 'allpages_address', 'ancientpages', 'ancientpages_address', 'broken_redirects_address', 'categories', 'categories_address', 'category_namespace', 'category_namespaces', 'category_on_one_line', 'checkCharset', 'cookies', 'deadendpages', 'deadendpages_address', 'delete_address', 'double_redirects_address', 'edit_address', 'encoding', 'encodings', 'export_address', 'family', 'forceLogin', 'getSite', 'getToken', 'getUrl', 'get_address', 'hostname', 'image_namespace', 'interwiki_putfirst', 'interwiki_putfirst_doubled', 'language', 'languages', 'linkto', 'loggedin', 'login_address', 'lonelypages', 'lonelypages_address', 'longpages', 'longpages_address', 'namespace', 'namespaces', 'newpages', 'newpages_address', 'purge_address', 'putToken', 'put_address', 'redirect', 'redirectRegex', 'references_address', 'shortpages', 'shortpages_address', 'sitename', 'template_namespace', 'uncategorizedcategories', 'uncategorizedcategories_address', 'uncategorizedpages', 'uncategorizedpages_address', 'unusedcategories', 'unusedcategories_address', 'upload_address', 'version', 'watchlist_address']
site._public_attrs_ = ['objectVer', 'objectName']
site._readonly_attrs_ = site._public_attrs_
return wrap(site, useDispatcher=useDispatcher)
开发者ID:pyropeter,项目名称:PyroBot-1G,代码行数:9,代码来源:wikicomserver.py
示例6: CreateObject
def CreateObject(self, typename):
try:
parts = typename.split(".")
item = __import__(".".join(parts[:-1]))
for part in parts[1:]:
item = getattr(item, part)
return util.wrap(item())
except:
raise COMException("No such type", winerror.DISP_E_BADVARTYPE)
开发者ID:edevil,项目名称:soaplib,代码行数:9,代码来源:comproxy.py
示例7: __init__
def __init__(self):
message_map = {
win32con.WM_DESTROY: self.OnDestroy,
win32con.WM_COMMAND: self.OnCommand,
win32con.WM_SIZE: self.OnSize,
}
# Register the Window class.
wc = win32gui.WNDCLASS()
hinst = wc.hInstance = win32api.GetModuleHandle(None)
wc.lpszClassName = "test_explorer_browser"
wc.lpfnWndProc = message_map # could also specify a wndproc.
classAtom = win32gui.RegisterClass(wc)
# Create the Window.
style = win32con.WS_OVERLAPPEDWINDOW | win32con.WS_VISIBLE
self.hwnd = win32gui.CreateWindow( classAtom, "Python IExplorerBrowser demo", style, \
0, 0, win32con.CW_USEDEFAULT, win32con.CW_USEDEFAULT, \
0, 0, hinst, None)
eb = pythoncom.CoCreateInstance(shellcon.CLSID_ExplorerBrowser, None, pythoncom.CLSCTX_ALL, shell.IID_IExplorerBrowser)
# as per MSDN docs, hook up events early
self.event_cookie = eb.Advise(wrap(EventHandler()))
eb.SetOptions(shellcon.EBO_SHOWFRAMES)
rect = win32gui.GetClientRect(self.hwnd)
# Set the flags such that the folders autoarrange and non web view is presented
flags = (shellcon.FVM_LIST, shellcon.FWF_AUTOARRANGE | shellcon.FWF_NOWEBVIEW)
eb.Initialize(self.hwnd, rect, (0, shellcon.FVM_DETAILS))
if len(sys.argv)==2:
# If an arg was specified, ask the desktop parse it.
# You can pass anything explorer accepts as its '/e' argument -
# eg, "::{guid}\::{guid}" etc.
# "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" is "My Computer"
pidl = shell.SHGetDesktopFolder().ParseDisplayName(0, None, sys.argv[1])[1]
else:
# And start browsing at the root of the namespace.
pidl = []
eb.BrowseToIDList(pidl, shellcon.SBSP_ABSOLUTE)
# and for some reason the "Folder" view in the navigator pane doesn't
# magically synchronize itself - so let's do that ourself.
# Get the tree control.
sp = eb.QueryInterface(pythoncom.IID_IServiceProvider)
try:
tree = sp.QueryService(shell.IID_INameSpaceTreeControl,
shell.IID_INameSpaceTreeControl)
except pythoncom.com_error as exc:
# this should really only fail if no "nav" frame exists...
print("Strange - failed to get the tree control even though " \
"we asked for a EBO_SHOWFRAMES")
print(exc)
else:
# get the IShellItem for the selection.
si = shell.SHCreateItemFromIDList(pidl, shell.IID_IShellItem)
# set it to selected.
tree.SetItemState(si, shellcon.NSTCIS_SELECTED, shellcon.NSTCIS_SELECTED)
#eb.FillFromObject(None, shellcon.EBF_NODROPTARGET);
#eb.SetEmptyText("No known folders yet...");
self.eb = eb
开发者ID:8dspaces,项目名称:Pywin32,代码行数:57,代码来源:explorer_browser.py
示例8: _TestEngine
def _TestEngine(self, engineName, code, expected_exc = None):
echoer = Test()
model = {
'test' : util.wrap(echoer),
}
site = MySite(model)
engine = site._AddEngine(engineName)
try:
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED)
engine.AddCode(code)
engine.Start()
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_STARTED)
self.failUnless(not echoer.fail_called, "Fail should not have been called")
# Now call into the scripts IDispatch
ob = Dispatch(engine.GetScriptDispatch())
try:
ob.hello("Goober")
self.failUnless(expected_exc is None,
"Expected %r, but no exception seen" % (expected_exc,))
except pythoncom.com_error:
if expected_exc is None:
self.fail("Unexpected failure from script code: %s" % (site.exception_seen,))
if expected_exc not in site.exception_seen[2]:
self.fail("Could not find %r in %r" % (expected_exc, site.exception_seen[2]))
return
self.assertEqual(echoer.last, "Goober")
self.assertEqual(str(ob.prop), "Property Value")
ob.testcollection()
self.failUnless(not echoer.fail_called, "Fail should not have been called")
# Now make sure my engines can evaluate stuff.
result = engine.eParse.ParseScriptText("1+1", None, None, None, 0, 0, axscript.SCRIPTTEXT_ISEXPRESSION)
self.assertEqual(result, 2)
# re-initialize to make sure it transitions back to initialized again.
engine.SetScriptState(axscript.SCRIPTSTATE_INITIALIZED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED)
engine.Start()
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_STARTED)
# Transition back to initialized, then through connected too.
engine.SetScriptState(axscript.SCRIPTSTATE_INITIALIZED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED)
engine.SetScriptState(axscript.SCRIPTSTATE_CONNECTED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_CONNECTED)
engine.SetScriptState(axscript.SCRIPTSTATE_INITIALIZED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED)
engine.SetScriptState(axscript.SCRIPTSTATE_CONNECTED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_CONNECTED)
engine.SetScriptState(axscript.SCRIPTSTATE_DISCONNECTED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_DISCONNECTED)
finally:
engine.Close()
engine = None
site = None
开发者ID:CoDEmanX,项目名称:ArangoDB,代码行数:56,代码来源:testHost.py
示例9: _TestEngine
def _TestEngine(self, engineName, code, bShouldWork = 1):
echoer = Test()
model = {
'test' : util.wrap(echoer),
}
try:
try:
site = MySite(model)
engine = site._AddEngine(engineName)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED)
engine.AddCode(code)
engine.Start()
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_STARTED)
finally:
if bShouldWork:
self.failUnless(not site.seen_exception, "Script site should not have seen an exception")
else:
self.failUnless(site.seen_exception, "Script site should have seen an exception")
self.failUnless(not echoer.fail_called, "Fail should not have been called")
# Now call into the scripts IDispatch
from win32com.client.dynamic import Dispatch
ob = Dispatch(engine.GetScriptDispatch())
ob.hello("Goober")
self.assertEqual(echoer.last, "Goober")
self.assertEqual(str(ob.prop), "Property Value")
ob.testcollection()
self.failUnless(not echoer.fail_called, "Fail should not have been called")
# Now make sure my engines can evaluate stuff.
result = engine.eParse.ParseScriptText("1+1", None, None, None, 0, 0, axscript.SCRIPTTEXT_ISEXPRESSION)
self.assertEqual(result, 2)
# re-initialize to make sure it transitions back to initialized again.
engine.SetScriptState(axscript.SCRIPTSTATE_INITIALIZED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED)
engine.Start()
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_STARTED)
# Transition back to initialized, then through connected too.
engine.SetScriptState(axscript.SCRIPTSTATE_INITIALIZED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED)
engine.SetScriptState(axscript.SCRIPTSTATE_CONNECTED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_CONNECTED)
engine.SetScriptState(axscript.SCRIPTSTATE_INITIALIZED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_INITIALIZED)
engine.SetScriptState(axscript.SCRIPTSTATE_CONNECTED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_CONNECTED)
engine.SetScriptState(axscript.SCRIPTSTATE_DISCONNECTED)
_CheckEngineState(site, engineName, axscript.SCRIPTSTATE_DISCONNECTED)
finally:
engine.Close()
engine = None
site = None
开发者ID:jakebarnwell,项目名称:PythonGenerator,代码行数:54,代码来源:testHost.py
示例10: TestEngine
def TestEngine(engineName, code, bShouldWork=1):
echoer = Test()
model = {"test": util.wrap(echoer)}
site = MySite(model)
engine = site._AddEngine(engineName)
engine.AddCode(code, axscript.SCRIPTTEXT_ISPERSISTENT)
try:
engine.Start()
finally:
if not bShouldWork:
engine.Close()
return
doTestEngine(engine, echoer)
# re-transition the engine back to the UNINITIALIZED state, a-la ASP.
engine.eScript.SetScriptState(axscript.SCRIPTSTATE_UNINITIALIZED)
engine.eScript.SetScriptSite(util.wrap(site))
print "restarting"
engine.Start()
# all done!
engine.Close()
开发者ID:hinike,项目名称:opera,代码行数:21,代码来源:leakTest.py
示例11: test
def test():
# Call via a native interface.
com_server = wrap(TestServer(), pythoncom.IID_IStream)
try:
com_server.Clone()
except pythoncom.com_error, com_exc:
hr, desc, exc, argErr = com_exc
if hr != winerror.E_UNEXPECTED:
raise error("Calling the object natively did not yield the correct scode", com_exc)
if not exc or exc[-1] != winerror.E_UNEXPECTED:
raise error("The scode element of the exception tuple did not yield the correct scode", com_exc)
if exc[2] != "Not today":
raise error("The description in the exception tuple did not yield the correct string", com_exc)
开发者ID:hkfr,项目名称:data,代码行数:13,代码来源:errorSemantics.py
示例12: TestMultiInterface
def TestMultiInterface():
o = wrap(Dummy2(), pythoncom.IID_IPersistStorage)
o2 = o.QueryInterface(pythoncom.IID_IExternalConnection)
FailObjectIdentity(o, o2, "IID_IPersistStorage->IID_IExternalConnection")
# Make the same QI again, to make sure it is stable.
o22 = o.QueryInterface(pythoncom.IID_IExternalConnection)
FailObjectIdentity(o, o22, "IID_IPersistStorage->IID_IExternalConnection")
FailObjectIdentity(o2, o22, "IID_IPersistStorage->IID_IExternalConnection (stability)")
o3 = o2.QueryInterface(pythoncom.IID_IPersistStorage)
FailObjectIdentity(o2, o3, "IID_IExternalConnection->IID_IPersistStorage")
FailObjectIdentity(o, o3, "IID_IPersistStorage->IID_IExternalConnection->IID_IPersistStorage")
开发者ID:89sos98,项目名称:main,代码行数:14,代码来源:testGatewayAddresses.py
示例13: AddEngine
def AddEngine(self, engine):
"""Adds a new engine to the site.
engine can be a string, or a fully wrapped engine object.
"""
if type(engine)==type(''):
newEngine = AXEngine(util.wrap(self), engine)
else:
newEngine = engine
self.engine = newEngine
flags = axscript.SCRIPTITEM_ISVISIBLE | axscript.SCRIPTITEM_NOCODE | axscript.SCRIPTITEM_GLOBALMEMBERS | axscript.SCRIPTITEM_ISPERSISTENT
for name in self.objModel.iterkeys():
newEngine.AddNamedItem(name, flags)
newEngine.SetScriptState(axscript.SCRIPTSTATE_INITIALIZED)
return newEngine
开发者ID:AT-GROUP,项目名称:AT-PLANNER,代码行数:14,代码来源:axsite.py
示例14: test
def test():
# Call via a native interface.
com_server = wrap(TestServer(), pythoncom.IID_IStream)
try:
com_server.Clone()
raise error("Expecting this call to fail!")
except pythoncom.com_error, com_exc:
if com_exc.hresult != winerror.E_UNEXPECTED:
raise error("Calling the object natively did not yield the correct scode", com_exc)
exc = com_exc.excepinfo
if not exc or exc[-1] != winerror.E_UNEXPECTED:
raise error("The scode element of the exception tuple did not yield the correct scode", com_exc)
if exc[2] != "Not today":
raise error("The description in the exception tuple did not yield the correct string", com_exc)
开发者ID:AT-GROUP,项目名称:AT-PLANNER,代码行数:14,代码来源:errorSemantics.py
示例15: wrap_complex_type
def wrap_complex_type(data, data_type):
for membername, membertype in data_type.soap_members.items():
member = getattr(data, membername)
if isinstance(member, ClassSerializer):
member = wrap_complex_type(member, membertype)
elif type(member) in [types.ListType, types.TupleType]:
newmember = []
for item in member:
if isinstance(item, ClassSerializer):
item = wrap_complex_type(item, item.__class__)
newmember.append(item)
member = newmember
setattr(data, membername, member)
data = util.wrap(data)
return data
开发者ID:edevil,项目名称:soaplib,代码行数:15,代码来源:comproxy.py
示例16: connect
def connect(self, event_driven=True):
"""
Connects to the RTD server.
Set event_driven to false if you to disable update notifications.
In this case you'll need to call refresh_data manually.
"""
dispatch = client.Dispatch(self._classid)
self._rtd = client.CastTo(dispatch, 'IRtdServer')
if event_driven:
self._rtd.ServerStart(wrap(self))
else:
self._rtd.ServerStart(None)
开发者ID:Qu-Bit,项目名称:pyrtd,代码行数:15,代码来源:client.py
示例17: TestGatewayInheritance
def TestGatewayInheritance():
# By default, wrap() creates and discards a temporary object.
# This is not necessary, but just the current implementation of wrap.
# As the object is correctly discarded, it doesnt affect this test.
o = wrap(Dummy(), pythoncom.IID_IPersistStorage)
o2 = o.QueryInterface(pythoncom.IID_IUnknown)
FailObjectIdentity(o, o2, "IID_IPersistStorage->IID_IUnknown")
o3 = o2.QueryInterface(pythoncom.IID_IDispatch)
FailObjectIdentity(o2, o3, "IID_IUnknown->IID_IDispatch")
FailObjectIdentity(o, o3, "IID_IPersistStorage->IID_IDispatch")
o4 = o3.QueryInterface(pythoncom.IID_IPersistStorage)
FailObjectIdentity(o, o4, "IID_IPersistStorage->IID_IPersistStorage(2)")
FailObjectIdentity(o2, o4, "IID_IUnknown->IID_IPersistStorage(2)")
FailObjectIdentity(o3, o4, "IID_IDispatch->IID_IPersistStorage(2)")
o5 = o4.QueryInterface(pythoncom.IID_IPersist)
FailObjectIdentity(o, o5, "IID_IPersistStorage->IID_IPersist")
FailObjectIdentity(o2, o5, "IID_IUnknown->IID_IPersist")
FailObjectIdentity(o3, o5, "IID_IDispatch->IID_IPersist")
FailObjectIdentity(o4, o5, "IID_IPersistStorage(2)->IID_IPersist")
开发者ID:89sos98,项目名称:main,代码行数:24,代码来源:testGatewayAddresses.py
示例18: SetGames
def SetGames(self, rom_name):
""" Return the IGames interface, by wrapping the object. """
games = IGames()
wrapped_games = wrap (games)
return wrapped_games
开发者ID:mjocean,项目名称:proc-visual-pinball,代码行数:5,代码来源:register_vpcom.py
示例19: SetSettings
def SetSettings(self):
settings = ISettings()
Settings = wrap( settings )
return Settings
开发者ID:mjocean,项目名称:proc-visual-pinball,代码行数:4,代码来源:register_vpcom.py
示例20: GetSetInterface
def GetSetInterface(self, ininterface):
return wrap(self)
开发者ID:89sos98,项目名称:main,代码行数:2,代码来源:test_pycomtest.py
注:本文中的win32com.server.util.wrap函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论