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 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('MaxI m.Document')
Application = win32com.client .Dispatch('MaxI m.Application')
p = win32com.client .dynamic.Dispat ch('PinPoint.Pl ate')
class TestThread ( threading.Threa d ):
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.OpenFi le('F:/Images/VRT/'+name)
Document.SaveFi le('F:/Images/VRT/'+
str(name[0:-4])+'.jpg', 6, 1024,2)
Application.Clo seAll()
try:
p.AttachFITS('F :/Images/VRT/'+name)
p.ArcsecPerPixe lHoriz = -1.7
p.ArcsecPerPixe lVert = -1.7
p.MaxMatchResid ual = 1.0
p.FitOrder = 3
p.CentroidAlgor ithm = 0
p.RightAscensio n = p.TargetRightAs cension
p.Declination = p.TargetDeclina tion
p.Catalog = 0 # GSC
p.CatalogPath = 'F:/'
p.ProjectionTyp e = 1 #
p.Solve()
p.DetachFITS()
pRA = p.RightAscensio n
pDec = p.Declination
print pRA
print pDec
except:
p.DetachFITS()
print 'Error'
before = after2
TestThread().st art()
For your prompt reply, I say thank you in advance.
Best regards,
Aleksandar 3 2168
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('MaxI m.Document') Application = win32com.client .Dispatch('MaxI m.Application') p = win32com.client .dynamic.Dispat ch('PinPoint.Pl ate')
class TestThread ( threading.Threa d ): 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().st art()
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
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\li b\threading.py" , line 442, in __bootstrap
self.run()
File "G:\Robot teleskop\VRT\te st\test2.py", line 25, in run
Document.OpenFi le('F:/Images/VRT/'+name)
File "C:\Program
Files\Python\Li b\site-packages\win32c om\client\dynam ic.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('MaxI m.Document')
Application = win32com.client .Dispatch('MaxI m.Application')
p = win32com.client .dynamic.Dispat ch('PinPoint.Pl ate')
class TestThread (threading.Thre ad):
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.OpenFi le('F:/Images/VRT/'+name)
Document.SaveFi le('F:/Images/VRT/'+
str(name[0:-4])+'.jpg', 6, 1024,2)
Application.Clo seAll()
try:
p.AttachFITS('F :/Images/VRT/'+name)
p.ArcsecPerPixe lHoriz = -1.7
p.ArcsecPerPixe lVert = -1.7
p.MaxMatchResid ual = 1.0
p.FitOrder = 3
p.CentroidAlgor ithm = 0
p.RightAscensio n = p.TargetRightAs cension
p.Declination = p.TargetDeclina tion
p.Catalog = 0 # GSC
p.CatalogPath = 'F:/'
p.ProjectionTyp e = 1 #
p.Solve()
p.DetachFITS()
pRA = p.RightAscensio n
pDec = p.Declination
print pRA
print pDec
except:
p.DetachFITS()
print 'Error'
before = after2
TestThread().st art()
"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" <za******@liber o.it> wrote in message
news:OQ******** *************@t wister1.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('MaxI m.Document') Application = win32com.client .Dispatch('MaxI m.Application') p = win32com.client .dynamic.Dispat ch('PinPoint.Pl ate')
class TestThread ( threading.Threa d ): 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().st art()
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
> Here the error message: Exception in thread Thread-1:
Traceback (most recent call last): File "C:\Program Files\Python\li b\threading.py" , line 442, in __bootstrap self.run() File "G:\Robot teleskop\VRT\te st\test2.py", line 25, in run Document.OpenFi le('F:/Images/VRT/'+name) File "C:\Program Files\Python\Li b\site-packages\win32c om\client\dynam ic.py", line 496, in __getattr__ raise AttributeError, "%s.%s" % (self._username _, attr) AttributeError: MaxIm.Document. OpenFile
Seems that you think it should doesn't impress the COM-object of type
MaxIm.Document very much. Play around with that w/o threads if it works.
Diez This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Anthony_Barker |
last post by:
I have been reading a book about the evolution of the Basic
programming language. The author states that Basic - particularly
Microsoft's version is full of compromises which crept in along the
language's 30+ year evolution.
What to you think python largest compromises are?
The three that come to my mind are significant whitespace,...
|
by: Jane Austine |
last post by:
As far as I know python's threading module models after Java's.
However, I can't find something equivalent to Java's interrupt and
isInterrupted methods, along with InterruptedException.
"somethread.interrupt()" will wake somethread up when it's in
sleeping/waiting state.
Is there any way of doing this with python's thread? I suppose thread...
|
by: Andrae Muys |
last post by:
Found myself needing serialised access to a shared generator from
multiple threads. Came up with the following
def serialise(gen):
lock = threading.Lock()
while 1:
lock.acquire()
try:
next = gen.next()
finally:
|
by: Egor Bolonev |
last post by:
hi all
my program terminates with error i dont know why it tells 'TypeError:
run() takes exactly 1 argument (10 given)'
=program====================
import os, os.path, threading, sys
def get_all_files(path):
"""return all files of folder path, scan with subfolders
|
by: Jon Skeet [C# MVP] |
last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the
article on all the groups this is posted to.
I've finally managed to finish my article on multi-threading - at least
for the moment. I'd be *very* grateful if people with any interest in
multi-threading would read it (even just bits of it - it's somewhat
long to go...
| |
by: Paul Sijben |
last post by:
I am stumped by the following problem. I have a large multi-threaded
server accepting communications on one UDP port (chosen for its supposed
speed).
I have been profiling the code and found that the UDP communication is
my biggest drain on performance! Communication where the client and the
server are on the same machine still takes 300ms...
|
by: OlafMeding |
last post by:
Below are 2 files that isolate the problem. Note, both programs hang
(stop responding) with hyper-threading turned on (a BIOS setting), but
work as expected with hyper-threading turned off.
Note, the Windows task manager shows 2 CPUs on the Performance tab with
hyper-threading is turned on.
Both Python 2.3.5 and 2.4.3 (downloaded from...
|
by: cgwalters |
last post by:
Hi,
I've recently been working on an application which does quite a bit
of searching through large data structures and string matching, and I
was thinking that it would help to put some of this CPU-intensive work
in another thread, but of course this won't work because of Python's
GIL.
There's a lot of past discussion on this, and I want...
|
by: CCLeasing |
last post by:
For an application I'm creating I want to create a 'fake' progress
bar.
By fake I mean a progress bar that looks like it's doing something but
actually isn't.
I know philosophically this isn't sound. But my little app is a 'fake'
app and is designed to look like another - hence this seeming crazy
situation of needing to fake a progess bar....
|
by: Dann Corbit |
last post by:
Rather than create a new way of doing things:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html
why not just pick up ACE into the existing standard:
http://www.cse.wustl.edu/~schmidt/ACE.html
the same way that the STL (and subsequently BOOST) have been subsumed?
Since it already runs on zillions of platforms, they have...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |