Coverage for lst_auto_rta/Auto_Calib_RTA.py: 0%
44 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-22 14:47 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-22 14:47 +0000
1#!/usr/bin/env python
3import datetime
4import os
6import pymongo
9def now():
10 return datetime.datetime.timestamp(datetime.datetime.now())
13def get_current_run():
14 client = pymongo.MongoClient("tcs05")
15 database = client["lst1_obs_summary"]
16 camera_collection = database["camera"]
17 summaries = camera_collection.find({})
18 run_table = []
19 for summary in summaries:
20 if summary["tstart"] > datetime.datetime.timestamp(datetime.datetime.now()) - 3600 * 8:
21 run_table.append(summary["run_number"])
22 return run_table[-1]
25def get_current_tstop():
26 client = pymongo.MongoClient("tcs05")
27 database = client["lst1_obs_summary"]
28 camera_collection = database["camera"]
29 summaries = camera_collection.find({})
30 for summary in summaries:
31 if summary["tstop"] > now():
32 print(summary["tstop"])
33 return summary["tstop"]
36import time
38current_run_is = -1
39quit = False
41os.system("cd /fefs/onsite/pipeline/rta/data")
43while quit == False:
44 time.sleep(1)
45 # print(current_run_is+1)
46 if current_run_is == -1:
47 current_run_is = get_current_run()
48 if get_current_run() is None:
49 print("None")
50 current_run_is = -1
51 continue
52 if current_run_is != get_current_run():
53 print("StartRTA for run ", get_current_run())
54 current_run_is = get_current_run()
55 print("scancel -u lstrta")
56 os.system("scancel -u lstrta")
57 time.sleep(2)
58 os.system(
59 "hiperta_stream_start --run_id "
60 + str(current_run_is + 1)
61 + " --config_file hiperta_stream_conf_20220927_listenAllLine.yml"
62 )
63 print(
64 "hiperta_stream_start --run_id ",
65 current_run_is + 1,
66 " --config_file hiperta_stream_conf_20220927_listenAllLine.yml",
67 )
68 # if (get_current_tstop() > now()):
69 # print(" Run",get_current_run()," ongoing")
70 # #os.system("squeue -u lstrta")
71 # else:
72 # print(" Run",get_current_run()," finished")
73 # print(" Stop RTA ")
74 # #os.system("scancel -u lstrta")
75 # print("scancel -u lstrta")