-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoreduce_monitor.py
executable file
·131 lines (106 loc) · 3.68 KB
/
autoreduce_monitor.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env python
import sys
from PyQt4 import QtGui, QtCore
from time import strftime
import datetime
import os
status_file = '/SNS/MANDI/shared/autoreduce/autoreduce_status.txt'
last_run_file = '/SNS/MANDI/shared/autoreduce/last_run_processed.dat'
with open(last_run_file, 'r') as f:
lastRun = int(f.readline())
with open(status_file, 'r') as f:
status = str(f.readline())
ipts_reading = int(f.readline())
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.Time)
self.timer.start(1000)
self.lbl1 = QtGui.QLabel('Initializing MaNDi Autoreduction', self)
self.lbl1.move(15, 10)
self.lbl1.resize(500, 15)
self.lbl2 = QtGui.QLabel(
'Last Run Processed: {0}'.format(lastRun), self)
self.lbl2.move(15, 40)
self.lbl2.resize(500, 15)
self.lbl3 = QtGui.QLabel('', self)
self.lbl3.move(15, 70)
self.lbl3.resize(500, 15)
self.lbl4 = QtGui.QLabel(
'Currently reading IPTS {}'.format(ipts_reading), self)
self.lbl4.move(15, 100)
self.lbl4.resize(500, 15)
self.setGeometry(300, 300, 500, 150)
self.setWindowTitle('MaNDi Autoreduction')
self.show()
def Time(self):
if int(strftime("%S")) % 10 == 0:
self.timer.setInterval(5000)
else:
self.timer.setInterval(5000)
with open(status_file, 'r') as f:
line = f.readline()
ipts_reading = f.readline()
self.lbl1.setText(line)
statbuf = os.stat(status_file)
datemod = datetime.datetime.fromtimestamp(statbuf.st_mtime)
now = datetime.datetime.now()
dt = now - datemod
if 'Finished' in line:
self.lbl2.setText("Finished at {}".format(str(datemod)))
self.lbl3.setText(
"Time since last finished analysis: {}".format(str(dt)))
else:
self.lbl2.setText(
"Started processing at {}".format(str(datemod)))
self.lbl3.setText(
"Time since started analysis: {}".format(str(dt)))
self.lbl4.setText(
"Currently scanning IPTS {}".format(str(ipts_reading)))
def main():
app = QtGui.QApplication(sys.argv)
ex = Example() # noqa: F841
sys.exit(app.exec_())
if __name__ == '__main__':
main()
"""
import sys, os, datetime
from PyQt4 import QtGui, QtCore
from time import strftime
status_file = '/SNS/MANDI/shared/autoreduce/autoreduce_status.txt'
class Main(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.initUI()
def initUI(self):
self.setWindowTitle('MaNDi autoreduction monitor')
self.timer = QtCore.QTimer(self)
self.timer.timeout.connect(self.Time)
self.timer.start(1000)
self.lcd1 = QtGui.QLineEdit()
self.lcd1.setText('MANDI_AutoReduction')
self.lcd1.move(20,20)
self.lcd1.resize(280,40)
self.setCentralWidget(self.lcd1)
self.setGeometry(0,0,320,150)
def Time(self):
if int(strftime("%S")) % 10 == 0:
self.timer.setInterval(5000)
else:
self.timer.setInterval(1000)
with open(status_file, 'r') as f:
line = f.readline()
statbuf = os.stat(status_file)
mod_time = str(datetime.datetime.fromtimestamp(statbuf.st_mtime))
self.lcd1.setText(line)
def main():
app = QtGui.QApplication(sys.argv)
main = Main()
main.show()
sys.exit(app.exec_())
if __name__ == "__main__":
main()
"""