diff --git a/webserver.py b/webserver.py index ac0a998..9ba3e00 100755 --- a/webserver.py +++ b/webserver.py @@ -14,7 +14,9 @@ import flask 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): @@ -376,7 +378,15 @@ a { chunk_list.sort(reverse=True) 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)) - args = ['='.join(key)] + port = None + if key[0] == 'instrument': + ins = key[1] + port = instruments.get(ins) + if port is None: + args = ['='.join(key)] + else: + host = f'http://{ins}.psi.ch:{port}' + args = [] if end > now: if begdate == today: daterange = f'since {time.strftime("%H:%M", time.localtime(beg))}' @@ -392,13 +402,15 @@ a { title('older than 30 days') showtitle = 2 - out.append(f'{key[1]} / {" ".join(devices)}') + out.append(f'{key[1]} / {" ".join(devices)}') out.append(f'{daterange}') if timerange: out.append(f'

earlier dates


') out.append('') - out.append('

servers on the instruments:

') - out.extend([f"{i} \n" for i in instlist]) + out.append('

central server

') + out.append('

direct link to instruments:

') + out.extend([f'{ins} \n' + for ins, port in instruments.items()]) out.extend(['', '']) except Exception as e: logging.error('%s', traceback.format_exc())