forked from GonzalezFJR/DTDOC_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
48 lines (42 loc) · 1.34 KB
/
run.py
File metadata and controls
48 lines (42 loc) · 1.34 KB
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
from TelegramDTDOC import *
nSecSleep = 10
TDT = TelegramDTDOC("YOUR_BOT_ADDRESS HERE")
nUpdateRun = 0
nUpdateComments = 0
nUpdateFill = 0
nNoRun = 0
isRun = True
while True:
# All kind of automatic notifications here!
try:
DownloadLHCpage1()
DownloadCMSpage1()
DownloadDAQpage()
TakeCMSpage1bits() # Fill and comments
TakeDAQpagebits() # Run and DT DAQ status
status = IsCMSpage1Updated()
nUpdateRun = 0 if not status['run' ] else (nUpdateRun+1)
nUpdateComments = 0 if not status['comments'] else (nUpdateComments+1)
nUpdateFill = 0 if not status['fill' ] else (nUpdateFill+1)
nNoRun = 0 if not status['norun' ] else (nNoRun+1)
except:
print('is there something wrong with the internet connexion?')
pass
if nUpdateRun >= 5:
nUpdateRun = 0
if nNoRun >= 3 and isRun:
isRun = False
TDT.UpdateCMSstatusNoRun()
elif nNoRun >= 3 and not isRun:
print('We have some update, but CMS is still not running!')
else:
isRun = True
TDT.UpdateCMSstatusRun()
if nUpdateComments >= 5:
nUpdateComments = 0
TDT.UpdateCMScomments()
if nUpdateFill >= 5:
nUpdateFill = 0
TDT.UpdateFill()
print(' >> ', GetTimestamp(), '[run = %d, comments = %d, fill = %d]'%(nUpdateRun, nUpdateComments, nUpdateFill))
time.sleep(nSecSleep)