I'm a little lost here.  It sounds lilke cscript is having problems in some
cases, and that Python may be having problems in the same situation.  This
sounds like a problem with the COM object.  I suspect running your script
from pythonwin would be closer to running from wscript.exe, but you don't
mention that.
 
It sounds a little like something is trying to write to stdout and failing
when being run as a GUI.  Have you tried asking the authors of the component
about the VB issue (ie, leaving Python out of the equation)?  That may help
you determine the issue when running under Python.
 
Mark

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Ronnie Jones
Sent: Monday, 6 June 2005 10:53 PM
To: [email protected]
Subject: [python-win32] Windows LogParser COM interface



I am trying to access LogParser 2.2 through the COM interface provided and I
am having a bit of a problem.  Here is what is going on:  First up is the
VBScript version of the code then comes the Python version.

 

Set objLogParser = CreateObject("MSUtil.LogQuery") Set objInputFormat =
_
CreateObject("MSUtil.LogQuery.FileSystemInputFormat")
objInputFormat.recurse = 0
Set objOutputFormat = _
CreateObject("MSUtil.LogQuery.NativeOutputFormat")
objOutputFormat.rtp = -1
strQuery = "SELECT Name, Size FROM 'C:\Program Files\Log Parser 2.2\*.*'

ORDER BY Name ASC"
objLogParser.ExecuteBatch strQuery, objInputFormat, objOutputFormat

When I installed Log Parsers 2.2 on WinXP home edition SP1 version 2002
it went in c:\Program Files\Log Parser 2.2 and then I ran regsvr32
LogParser.dll from that directory. The error I get is :

Error executing query:Error while writing to file: The handle is
invalid.

NOW!! This occurs when I run the script from the command line just by typing
the script name and letting XP load cscript. However if I type:
cscript test.vbs from the command line it runs ok. Now what I am trying to
do is program this interface from ActiveState python 2.3 with win32com
extentions. Everything works fine but when I run the script I get the same
error I get when I type 'test.vbs' at the command line. Python is my main
language and I would really like to make it work. It seems like there is
some condition of having the script directly called from 'cscript' for the
COM interface to work. Does anyone know the workings of the COM interface. I
understand the API, but how are the calls being made. Here is the python
code for the same example:

>>> import win32com.client
>>> objLogParser = win32com.client.Dispatch("MSUtil.LogQuery")
>>> objOutput =
win32com.client.Dispatch("MSUtil.LogQuery.NativeOutputFormat")
>>> objOutput.rtp = -1
>>> objInput =
win32com.client.Dispatch("MSUtil.LogQuery.FileSystemInputFormat")
>>> objInput.recurse = 0
>>> myquery = "SELECT Name, Size FROM 'C:/lame/misc/*.*' ORDER BY Name ASC"
>>> objLogParser.ExecuteBatch(myquery, objInput, objOutput)

Traceback (most recent call last):
File "", line 1, in ?
File
"C:\Python23\Lib\site-packages\win32com\gen_py\A7E75D86-41CD-4B6E-B4BD-CC2ED
34B3FB0x0x1x0.py", line 819, in ExecuteBatch
return self._oleobj_.InvokeTypes(2, LCID, 1, (11, 0), ((8, 1), (13, 49),
(13, 49)),szQuery, pObjectInputContext, pObjectOutputContext)
com_error: (-2147352567, 'Exception occurred.', (0, 'CLogQueryClass', 'Error
executing query: Error while writing to file: The handle is invalid. [The
handle is invalid.]', None, 0, -2147024890), None)


Any ideas would be appreciated. I can run the select command at the
command line using LogParser.exe and all is well but not with COM.

Thank you,

Ronnie Jones

<<attachment: winmail.dat>>

_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to