I am writing a wrapper library for the windows IMAPIv2 com object and
am having trouble getting my event listener connected.
Everything works great if I comment out the event hooks.
Here is the code:
def run(self):
# duplicate objects because this is a different thread
self.Recorder = CreateObject("IMAPI2.MsftDiscRecorder2")
self.Recorder.InitializeDiscRecorder(self.drive.get_drive())
self.DataWriter = CreateObject("IMAPI2.MsftDiscFormat2Data")
self.DataWriter.Recorder = self.Recorder
self.DataWriter.ClientName = "WinBurn IMAPIv2"
#help(self.DataWriter)
if not self.DataWriter.IsCurrentMediaSupported(self.Recorder):
print "No disc in drive or unsupported media!"
self.status = RECORDER_RESULT_ERROR
else:
# connect signal handler
# uncomment the following line for a signal dump
ev = ShowEvents(self.DataWriter)
#self.sink = self.EventSink(self.parent)
#self.connection = GetEvents(self.DataWriter, self.sink)
if self.DataWriter.NextWritableAddress == 0:
self.DataWriter.SetWriteSpeed(self.speed, False)
self.DataWriter.Write(self.tracks[0].getStream())
self.Recorder.EjectMedia()
self.status = RECORDER_RESULT_FINISHED
else:
self.Recorder.EjectMedia()
self.status = RECORDER_RESULT_ERROR
And this is the event sink, although I haven't even gotten ShowEvents
working ...
# catch and process all events here. Uncomment the ShowEvents line
above
# to get a complete dump of all events generated
class EventSink(object):
def __init__(self, parent):
self.parent = parent
def dwBurnEvent_Update(self, this, progress):
totalSectors = progress.SectorCount
writtenSectors = progress.LastWrittenLba -
progress.StartLba
percentDone = FormatPercent(writtenSectors/totalSectors)
self.parent.emit('progress-changed', percentDone)
This is the error it outputs:
File "C:\Documents and Settings\Administrator\Desktop\stomper
\stomper\winburn.
py", line 138, in run
ev = ShowEvents(self.DataWriter)
File "c:\Python25\lib\site-packages\comtypes\client\_events.py",
line 229, in
ShowEvents
return comtypes.client.GetEvents(source, sink=EventDumper(),
interface=inter
face)
File "c:\Python25\lib\site-packages\comtypes\client\_events.py",
line 205, in
GetEvents
rcv = GetDispEventReceiver(interface, sink)
File "c:\Python25\lib\site-packages\comtypes\client\_events.py",
line 163, in
GetDispEventReceiver
for memid, name in _get_dispmap(itf).iteritems():
File "c:\Python25\lib\site-packages\comtypes\client\_events.py",
line 40, in _
get_dispmap
for tag, name, idlflags, restype, argtypes in
interface._disp_methods_:
AttributeError: type object 'DDiscFormat2DataEvents' has no attribute
'_disp_met
hods_'
Any ideas?
-b
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
comtypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/comtypes-users