select_experiment: use links to instruments
This commit is contained in:
20
webserver.py
20
webserver.py
@ -14,7 +14,9 @@ import flask
|
|||||||
import circularlog
|
import circularlog
|
||||||
|
|
||||||
|
|
||||||
instlist = ['AMOR', 'BOA', 'CAMEA', 'DMC', 'EIGER', 'FOCUS', 'HRPT', 'SANS', 'TASP', 'ZEBRA']
|
instruments = {ins: 8642 for ins in
|
||||||
|
['amor', 'boa', 'camea', 'dmc', 'eiger', 'focus', 'hrpt', 'sans', 'tasp', 'zebra']
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def guess_mimetype(filename):
|
def guess_mimetype(filename):
|
||||||
@ -376,7 +378,15 @@ a {
|
|||||||
chunk_list.sort(reverse=True)
|
chunk_list.sort(reverse=True)
|
||||||
for end, beg, key, devices in chunk_list:
|
for end, beg, key, devices in chunk_list:
|
||||||
today, begdate, enddate = (time.strftime("%Y-%m-%d", time.localtime(t)) for t in (now, beg, end))
|
today, begdate, enddate = (time.strftime("%Y-%m-%d", time.localtime(t)) for t in (now, beg, end))
|
||||||
|
port = None
|
||||||
|
if key[0] == 'instrument':
|
||||||
|
ins = key[1]
|
||||||
|
port = instruments.get(ins)
|
||||||
|
if port is None:
|
||||||
args = ['='.join(key)]
|
args = ['='.join(key)]
|
||||||
|
else:
|
||||||
|
host = f'http://{ins}.psi.ch:{port}'
|
||||||
|
args = []
|
||||||
if end > now:
|
if end > now:
|
||||||
if begdate == today:
|
if begdate == today:
|
||||||
daterange = f'since {time.strftime("%H:%M", time.localtime(beg))}'
|
daterange = f'since {time.strftime("%H:%M", time.localtime(beg))}'
|
||||||
@ -392,13 +402,15 @@ a {
|
|||||||
title('older than 30 days')
|
title('older than 30 days')
|
||||||
showtitle = 2
|
showtitle = 2
|
||||||
|
|
||||||
out.append(f'<tr><th><a href="/?{"&".join(args)}">{key[1]} / {" ".join(devices)}</a></th>')
|
out.append(f'<tr><th><a href="{host}/?{"&".join(args)}">{key[1]} / {" ".join(devices)}</a></th>')
|
||||||
out.append(f'<td>{daterange}</td></tr>')
|
out.append(f'<td>{daterange}</td></tr>')
|
||||||
if timerange:
|
if timerange:
|
||||||
out.append(f'<h3><a href="/select_experiment?time=all">earlier dates</a></h3><br>')
|
out.append(f'<h3><a href="/select_experiment?time=all">earlier dates</a></h3><br>')
|
||||||
out.append('</table>')
|
out.append('</table>')
|
||||||
out.append('<h3>servers on the instruments:</h3>')
|
out.append('<h3><a href="http://linse-c.psi.ch:8888/">central server</a></h3>')
|
||||||
out.extend([f"<a href='http://{i.lower()}.psi.ch:8642/'>{i}</a> \n" for i in instlist])
|
out.append('<h3>direct link to instruments:</h3>')
|
||||||
|
out.extend([f'<a href="http://{ins}.psi.ch:{port}/">{ins}</a> \n'
|
||||||
|
for ins, port in instruments.items()])
|
||||||
out.extend(['</body></html>', ''])
|
out.extend(['</body></html>', ''])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error('%s', traceback.format_exc())
|
logging.error('%s', traceback.format_exc())
|
||||||
|
Reference in New Issue
Block a user