Threating problem

A

Aleksandar Cikota

Hi all,

I have a problem with threading. The following part should be running in a
main programm all the time, but so that the main programm also works (like 2
seperate programms, but in one)
How to integrate the part in the main programm?

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/"
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()




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

Best regards,
Aleksandar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
DewittMill
Top