[python-win32] Questions about deploying COM server via py2exe
wtwinsoftware at gmail.com
Sat Aug 20 20:30:38 CEST 2011
Thanks for the suggestions. I have integrated the win32trace module into my frozen app. Here is my final code:
from quickwho_main import quickwhoApp
from win32com.server.exception import COMException
sys.stdout = open('C:/Users/Kevin/Desktop/my_stdout.log', 'w')
sys.stderr = open('C:/Users/Kevin/Desktop/my_stderr.log', 'w')
#expose basic functionality to COM
_public_methods_ = ['GetDomain']
_reg_progid_ = 'QuickWho.Application'
def GetDomain(self, domain):
tempfile = tempfile.gettempdir()+ '/urltext.txt'
data = open(tempfile, 'r')
finaltext = data.read()
except Exception ,ex:
exMsg='Unable to retrieve domain data '+str(ex)
app = quickwhoApp(None)
except Exception ,ex:
print "error !! " + str(ex)
(I put the code into a frozen app because it isn’t practical to debug the app itself when run as a Python module—it won’t be deployed that way.)
I did get some debugging output, though not what I expected:
Exception in Tkinter callback
Traceback (most recent call last):
File "Tkinter.pyc", line 1410, in __call__
File "quickwho_main.pyc", line 159, in <lambda>
File "quickwho_main.pyc", line 253, in getInfo
File "subprocess.pyc", line 537, in check_output
File "subprocess.pyc", line 672, in __init__
File "subprocess.pyc", line 784, in _get_handles
File "subprocess.pyc", line 823, in _make_inheritable
WindowsError: [Error 6] The handle is invalid
This appears to be related to the bug logged at http://bugs.python.org/issue3905. My app makes use of subprocess to obtain various bits of data that it then parses and displays in its UI. For what it’s worth, injecting the trace module into my frozen app causes no output to appear at all in the app itself, and returns the error above; the trace module seems to trigger the suprocess bug. However, it seems to have no bearing at all on the failure of VBScript to create a COM object from my application, and the debugging output logged to my stdout/stderr file did not yield any insight on that.
I investigated whether running the mainloop() in the app might interfere with the application receiving the COM request from the Windows Script Host, but commenting out the mainloop only caused the app to crash (since Tkinter apps require a mainloop to run).
The bottom line of all this investigation is that I am no closer to understanding why my Tkinter app does not respond to the CreateObject request from VBS. It appears that those requests simply disappear into a black hole. It also appears that integrating a GUI toolkit with its own event loop in Python may not be very practical with a COM server (see http://trac.wxwidgets.org/ticket/12105 for some other issues with wxPython and COM). Unfortunately, this means my best option is probably to move ahead without COM support.
Thanks again for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the python-win32