How do you debug win32 com integration from Python?
I'm trying to call the text to speech API from Python using win32com.client. The Python interpreter is bundled with Splunk and I'm able to invoke it manually using "splunk cmd python".
Here's a sample
from win32com.client import constants
import win32com.client
speaker = win32com.client.Dispatch("SAPI.SpVoice")
speaker.Speak('this is a test')
My code is invoked via the splunkd 开发者_Go百科process (running as a normal windows user) and I get the following error message.
(-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147200925), None)
I'm struggling to troubleshoot the problem, any suggestions?
The bundled Python version is Python 2.6.4 (r264:75706, Feb 7 2011, 14:20:39) [MSC v.1400 64 bit (AMD64)]
Cross-posted from Splunk Answers http://splunk-base.splunk.com/answers/31181/debugging-custom-search-commands
== update == I've tracked the problem down to the process launching the python interpreter. For some reason the processes messes with the environment in such a way that the python interpreter behaves differently. I suspect the win32 error is actually an access violation.
The application runs as expected when launched as a normal user. The parent process runs as system, which fails to invoke the TTS.
精彩评论