Threading problem

Aleksandar Cikota alexci at web.de
Mon Apr 17 18:35:42 EDT 2006


Thank You, but now it cannot open a file, but it should work...

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



And here the 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':
                            Document.OpenFile('F:/Images/VRT/'+name)
                            Document.SaveFile('F:/Images/VRT/'+ 
str(name[0:-4])+'.jpg', 6, 1024,2)
                            Application.CloseAll()
                            try:
                                p.AttachFITS('F:/Images/VRT/'+name)
                                p.ArcsecPerPixelHoriz = -1.7
                                p.ArcsecPerPixelVert = -1.7
                                p.MaxMatchResidual = 1.0
                                p.FitOrder = 3
                                p.CentroidAlgorithm = 0
                                p.RightAscension = p.TargetRightAscension
                                p.Declination = p.TargetDeclination
                                p.Catalog = 0  # GSC
                                p.CatalogPath = 'F:/'
                                p.ProjectionType = 1 #
                                p.Solve()
                                p.DetachFITS()
                                pRA = p.RightAscension
                                pDec = p.Declination
                                print pRA
                                print pDec
                            except:
                                p.DetachFITS()
                                print 'Error'
                before = after2
TestThread().start()




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


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

Best regards,
Aleksandar




"Faber" <zannablu at libero.it> wrote in message 
news:OQT0g.86761$A83.2055356 at twister1.libero.it...
> Aleksandar Cikota wrote:
>
>> How to integrate the Code-part in the main programm, so that the
>> mainprogramm works?
>>
>> 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 ):
>>     path_to_watch = "F:/Images/VRT/"
>
>    def run(self):
>        # Put the following code in the run method
>
>>     before = dict ([(f, None) for f in os.listdir (path_to_watch)])
>>     while 1:
>
> [cut]
>
>> TestThread().start()
>
> This should work
>
> -- 
> Faber
> http://faberbox.com/
> http://smarking.com/
>
> The man who trades freedom for security does not deserve nor will he ever
> receive either. -- Benjamin Franklin 





More information about the Python-list mailing list