List Info

Thread: Threading problem




Threading problem
user name
2006-04-18 13:01:10
 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.
 
Code:
 
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:
     ;   time.sleep(2)
     ;   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
 ;           ;           ;     Document.OpenFile('F:/Images/VRT/'+name)
         ;           ;        Document.SaveFile('F:/Images/VRT/'+ str(name[0:-4])+'.jpg', 6, 1024,2)
      ;           ;           Application.CloseAll()
         ;       before = after2
TestThread().start()
 
 
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
    self.run()
  File "G:\Robot teleskop\VRT\test\test2.py", line 25, in run
   ; Document.OpenFile('F:/Images/VRT/'+name)
  File "C:\Program
Files\Python\Lib\site-packages\win32com\client\dynamic.py", line 496, in
__getattr__
    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,
Aleksandar
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )