[python-win32] Windows LogParser COM interface

Tim Roberts timr at probo.com
Mon Jun 6 19:41:08 CEST 2005


On Mon, 6 Jun 2005 08:52:46 -0400, "Ronnie Jones" 
<7qrj45 at clayelectric.com> wrote:

>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.
>
> ...
>
>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-C
>C2ED34B3FB0x0x1x0.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)
>  
>

Well, I cut and pasted your code as-is onto my XP SP2 system, and it 
worked perfectly.

As Mark said, however, you can't run this within a GUI app.  If you put 
this in a "pyw" file, or if you launch it with pythonw, it won't work, 
because there is no stdout to write to.  The fact that the traceback 
shows "file "", line 1, in ?" tells me that you might be running it from 
inside a GUI, and not from a real command line.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-win32 mailing list