-
Notifications
You must be signed in to change notification settings - Fork 0
/
runXia2.py
executable file
·52 lines (43 loc) · 1.18 KB
/
runXia2.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
#!/usr/bin/python
import time
import os
import sys
import db_lib
import json
import daq_utils
directory = sys.argv[1]
runningDir = directory+"/xia2Output"
comm_s = "mkdir -p " + runningDir
os.system(comm_s)
os.chdir(runningDir)
filePrefix = sys.argv[2]
numstart = int(sys.argv[3])
numimages = int(sys.argv[4])
request_id = int(sys.argv[5])
expectedFilenameList = []
timeoutLimit = 60 #for now
prefix_long = directory+"/"+filePrefix
for i in range (numstart,numstart+numimages):
filename = daq_utils.create_filename(prefix_long,i)
expectedFilenameList.append(filename)
#for i in range (0,len(expectedFilenameList)):
# print expectedFilenameList[i]
timeout_check = 0
while(not os.path.exists(expectedFilenameList[len(expectedFilenameList)-1])): #this waits for images
timeout_check = timeout_check + 1
time.sleep(1.0)
if (timeout_check > timeoutLimit):
break
comm_s = "xia2 " + directory
print comm_s
os.system(comm_s)
#result = {}
#result["timestamp"] = time.time()
#result["type"] = "xia2"
fd = open("xia2.json")
resultObj = json.loads(fd.read())
fd.close()
print resultObj
#result["resultObj"] = resultObj
db_lib.addResultforRequest("xia2",request_id,resultObj)
print "finished xia2"