Capturing OutputDebugString information in python

2007-10-16 Thread danbrotherston
Hello,

I am trying to get the output from the win32 platform command
OutputDebugString.  I have used the following C++ code as a
guideline:

http://groups.google.com/group/microsoft.public.vc.utilities/browse_frm/thread/1434418cb968d053/1a3c957675242c7e?lnk=st&q=DBWIN_BUFFER&rnum=3#1a3c957675242c7e

And I have been able to translate most things into python, but I have
been unable to get it to work.  I use the pywin extensions to call
CreateEvent and create the required events.  But when I wait on the
event using the WaitOnSingleEvent call, it hangs indefinitely even
when I make calls to OutputDebugString in other processes, (both
python processes using win32api and actual C++ win32 programs).  I
also used mmap to map a file (using fileno -1) to the "DBWIN_BUFFER"
but that buffer appears to be empty all the time no matter the calls
to OutputDebugString.

I have limited experience with this part of windows, but if anyone had
any ideas I'd appreciate it greatly.

Thanks,

Daniel

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Capturing OutputDebugString information in python

2007-10-18 Thread danbrotherston


Wow, more of a response than I expected, thanks very much for the
research.  While not related to the mutex, the problem did appear to
be permission related.  For the record, on windows XP

import sys
import mmap
import win32event

buffer_ready = win32event.CreateEvent (None, 0, 0,
"DBWIN_BUFFER_READY")
data_ready = win32event.CreateEvent (None, 0, 0, "DBWIN_DATA_READY")
buffer = mmap.mmap (0, 4096, "DBWIN_BUFFER", mmap.ACCESS_WRITE)


win32event.SetEvent (buffer_ready)


while win32event.WaitForSingleObject (data_ready, 1000) ==
win32event.WAIT_TIMEOUT:
   print "Timed out"

print "Was signaled"

appears to work.  Write access appears to be required for the buffer
(which I can read and get useful data from:

print buffer.read(4)
print buffer.read(4092)

and no security object.  I wasn't the one who figured this out, so I'm
really not sure why it works...but it seems to.


-- 
http://mail.python.org/mailman/listinfo/python-list