Updated WSGI html python script
This commit is contained in:
@@ -1,38 +1,63 @@
|
|||||||
# https://tecadmin.net/install-apache-mod-wsgi-on-ubuntu-16-04-xenial
|
#!/usr/bin/env python3
|
||||||
# Include in /etc/apache2/conf-available/mod-wsgi.conf :
|
# -*- coding: utf-8 -*-
|
||||||
# WSGIScriptAlias /isttok /var/www/html/wsgi_isttok_status.py
|
# if you change this script "touch" it to reload by apache
|
||||||
# and
|
# e.g touch /var/www/html/wsgi_isttok_status.py
|
||||||
# systemctl restart apache2
|
"""
|
||||||
|
Created on December 8 16:34:35 2019
|
||||||
|
https://tecadmin.net/install-apache-mod-wsgi-on-ubuntu-16-04-xenial
|
||||||
|
|
||||||
|
Install:
|
||||||
|
Include in /etc/apache2/conf-available/mod-wsgi.conf :
|
||||||
|
WSGIScriptAlias /isttok /var/www/html/wsgi_isttok_status.py
|
||||||
|
and do:
|
||||||
|
systemctl restart apache2
|
||||||
|
|
||||||
|
@author: bernardo carvalho@IPFN
|
||||||
|
"""
|
||||||
#
|
#
|
||||||
#import epics
|
|
||||||
from epics import caget, caput, cainfo
|
from epics import caget, caput, cainfo
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
#os.environ['EPICS_CA_ADDR_LIST'] = 'localhost 192.168.1.110 192.168.1.120'
|
||||||
os.environ['EPICS_CA_ADDR_LIST'] = 'localhost 192.168.1.110'
|
os.environ['EPICS_CA_ADDR_LIST'] = 'localhost 192.168.1.110'
|
||||||
os.environ['EPICS_CA_AUTO_ADDR_LIST'] = 'NO'
|
os.environ['EPICS_CA_AUTO_ADDR_LIST'] = 'NO'
|
||||||
|
|
||||||
def application(environ,start_response):
|
def application(environ,start_response):
|
||||||
status = '200 OK'
|
status = '200 OK'
|
||||||
RPump1press = caget('ISTTOK:central:RPump1-Pressure')
|
RPump1press = caget('ISTTOK:central:RPump1-Pressure', as_string=True)
|
||||||
RPump2press = caget('ISTTOK:central:RPump2-Pressure')
|
# RPump2press = caget('ISTTOK:central:RPump2-Pressure')
|
||||||
TMPump1press = caget('ISTTOK:central:TMPump1-PressureAdmission')
|
TMPump1press = caget('ISTTOK:central:TMPump1-PressureAdmission', as_string=True)
|
||||||
VVesselpress = caget('ISTTOK:central:VVessel-Pressure')
|
VVesselpress = caget('ISTTOK:central:VVessel-Pressure', as_string=True)
|
||||||
rpiCurrentTime = caget('ISTTOK:central:CurrentTime')
|
# RPump1press = caget('ISTTOK:vacuum:RPump1-Pressure')
|
||||||
opState = caget('ISTTOK:central:OPSTATE.VAL')
|
# RPump2press = caget('ISTTOK:vacuum:RPump2-Pressure')
|
||||||
pulseNum = caget('ISTTOK:central:PULSE-NUMBER')
|
# TMPump1press = caget('ISTTOK:vacuum:TMPump1-PressureAdmission')
|
||||||
|
# VVesselpress = caget('ISTTOK:vacuum:VVessel-Pressure')
|
||||||
|
rpiCurrentTime = caget('ISTTOK:central:CurrentTime', as_string=True)
|
||||||
|
opState = caget('ISTTOK:central:OPSTATE.VAL', as_string=True)
|
||||||
|
pulseNum = caget('ISTTOK:central:PULSE-NUMBER', as_string=True)
|
||||||
|
OnBattery = caget('ISTTOK:central:UPS-OnBattery', as_string=True)
|
||||||
|
# cainfo not working
|
||||||
|
RPump1Info = cainfo("ISTTOK:central:RPump1-Pressure", print_out=False)
|
||||||
html = '<html>\n' \
|
html = '<html>\n' \
|
||||||
'<body>\n' \
|
'<head> <meta charset="UTF-8"/> <title>ISTTOK Status page</title>' \
|
||||||
' <h1> ISTTOK Present Condition </h1> \n'
|
'<meta http-equiv="refresh" content="5"> </head>' \
|
||||||
html += '<p>RPump1-Pressure: ' + str(RPump1press) + ' mBar </p>'
|
'<body>\n <h1> ISTTOK Present Condition </h1> \n'
|
||||||
html += '<p>RPump2-Pressure: ' + str(RPump2press) + ' mBar </p>'
|
# html += '<p>RPump1-Pressure: ' + str(RPump1press) + ' mBar </p>'
|
||||||
html += '<p>TMPump1-PressureAdmission: ' + str(TMPump1press) + ' mBar </p>'
|
html += '<p>RPump1-Pressure: ' + RPump1press + ' mBar </p>'
|
||||||
html += '<p>VVessel-Pressure: ' + str(VVesselpress) + ' mBar </p>'
|
# html += '<p>RPump2-Pressure: ' + str(RPump2press) + ' mBar </p>'
|
||||||
html += '<p>OPSTATE: ' + str(opState) + ' </p>'
|
html += '<p>TMPump1-PressureAdmission: ' + TMPump1press + ' mBar </p>'
|
||||||
html += '<p>PULSE-NUMBER: ' + str(pulseNum) + ' </p>'
|
html += '<p>VVessel-Pressure: ' + VVesselpress + ' mBar </p>'
|
||||||
html += '<p>Rpi CurrentTime: ' + str(rpiCurrentTime) + ' </p>'
|
html += '<p>OPSTATE: ' + opState + ', UPS-OnBattery: '+ OnBattery+ '</p>'
|
||||||
|
html += '<p>Note: you can try to login to rpi-isttok machine and do: '
|
||||||
|
html += '<pre>caput ISTTOK:central:OPREQ START</pre> </p>'
|
||||||
|
html += '<p>PULSE-NUMBER: ' + pulseNum + ' </p>'
|
||||||
|
html += '<p>Rpi CurrentTime: ' + rpiCurrentTime + ' </p>'
|
||||||
|
html += '<pre> ' + RPump1Info + '</pre>'
|
||||||
html += '</body>\n' \
|
html += '</body>\n' \
|
||||||
'</html>\n'
|
'</html>\n'
|
||||||
response_header = [('Content-type','text/html')]
|
response_header = [('Content-type','text/html'),
|
||||||
|
('Content-Length', str(len(html)))]
|
||||||
start_response(status,response_header)
|
start_response(status,response_header)
|
||||||
html = bytes(html, encoding= 'utf-8')
|
return [html.encode('UTF-8')]
|
||||||
return [html]
|
# html = bytes(html, encoding= 'utf-8')
|
||||||
|
# return [html]
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ mail_end {
|
|||||||
send {
|
send {
|
||||||
mail_start;
|
mail_start;
|
||||||
out "Problem is: %s\n";
|
out "Problem is: %s\n";
|
||||||
out "Please check: http://epics.ipfn.ist.utl.pt/isttok";
|
out "Please check: http://epics.ipfn.tecnico.ulisboa.pt/isttok";
|
||||||
mail_end;
|
mail_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# autosave R5.3 Automatically generated - DO NOT MODIFY - 211215-162845
|
# autosave R5.3 Automatically generated - DO NOT MODIFY - 211215-181848
|
||||||
ISTTOK:central:PULSE-NUMBER.VAL 49461
|
ISTTOK:central:PULSE-NUMBER.VAL 49461
|
||||||
ISTTOK:central:LogMessage.VAL
|
ISTTOK:central:LogMessage.VAL
|
||||||
ISTTOK:central:LASTOPSTATE.VAL 2
|
ISTTOK:central:LASTOPSTATE.VAL 2
|
||||||
|
|||||||
Reference in New Issue
Block a user