[python-win32] Threading problem

Aleksandar Cikota alexci at gmx.net
Tue Apr 18 15:01:10 CEST 2006

 Hi all,

I have a problem with threading. 
It should work, but it cannot open a file (Document.OpenFile) if "def run
(self):"  is in the code. Else the programm doesn't work.


import win32com.client
import time
import os
import threading
Document = win32com.client.Dispatch('MaxIm.Document')
Application = win32com.client.Dispatch('MaxIm.Application')
p = win32com.client.dynamic.Dispatch('PinPoint.Plate')
class TestThread (threading.Thread):
    def run (self):
      path_to_watch = "F:/Images/VRT/"  
      before = dict ([(f, None) for f in os.listdir (path_to_watch)])
      while 1:
        after2 = dict ([(f, None) for f in os.listdir (path_to_watch)])
        added = [f for f in after2 if not f in before]
        if added:
                name= ' ,'.join (added)
                if str(name[-3:])=='fit':
                            print name
str(name[0:-4])+'.jpg', 6, 1024,2)
                before = after2

Here the error message:

>>> Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Program Files\Python\lib\threading.py", line 442, in __bootstrap
  File "G:\Robot teleskop\VRT\test\test2.py", line 25, in run
  File "C:\Program 
Files\Python\Lib\site-packages\win32com\client\dynamic.py", line 496, in 
    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: MaxIm.Document.OpenFile

What does raise AttributeError, "%s.%s" % (self._username_, attr) mean?

If I use win32com.client.gencache.EnsureDispatch() in place of Dispatch the
error message looks like that:

Traceback (most recent call last):
  File "G:\Robot teleskop\VRT\soft\GUI.py", line 18, in -toplevel-
    Document = win32com.client.gencache.EnsureDispatch("MaxIm.Document")
  File "C:\Program Files\Python\Lib\site-packages\win32com\client\gencache
py", line 543, in EnsureDispatch
    raise TypeError, "This COM object can not automate the makepy process -
please run makepy manually for this object"
TypeError: This COM object can not automate the makepy process - please run
makepy manually for this object

What should I do? I hope You can help me.

For your prompt reply, I say thank you in advance.

Best regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20060418/5679c6cf/attachment.htm 

More information about the Python-win32 mailing list