-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscatomtzrunthread.py
49 lines (44 loc) · 1.7 KB
/
scatomtzrunthread.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
from scalepacktomtzrunscriptcreator import ScalePackToMtzRunscriptCreator
from process_multi_util_functions import report
from threading import Thread
import sys
import subprocess
import time
import pprint
class ScaToMtzRunThread(Thread):
def __init__(self, in_queue, out_queue,auriga_output_directory_root):
Thread.__init__(self)
self.in_queue = in_queue
self.out_queue = out_queue
self.auriga_output_directory_root = auriga_output_directory_root
sys.excepthook = self.report_error
def report_error(type=None,value=None,traceback=None):
if type is OSError:
print ("***FilenameError***",value.filename)
sys.__excepthook__(type,value,traceback)
else:
sys.__excepthook__(type,value,traceback)
def run(self):
while True:
path = self.in_queue.get()
if path == None:
self.out_queue.put(None)
self.in_queue.task_done()
break
myfile = ScalePackToMtzRunscriptCreator(path,self.auriga_output_directory_root)
scrfile = myfile.create_and_return_runscript_file()
time.sleep(2)
try:
subprocess.Popen([scrfile],close_fds=True).wait()
# time.sleep(2)
except subprocess.CalledProcessError:
self.in_queue.put(path)
self.in_queue.task_done()
continue
except OSError:
self.in_queue.put(path)
self.in_queue.task_done()
continue
self.out_queue.put(myfile.mtzoutpath())
self.in_queue.task_done()