Skip to content
Snippets Groups Projects
Commit ad7845cf authored by Mikhail Karnevskiy's avatar Mikhail Karnevskiy
Browse files

Add dark overview

parent f0f85334
No related branches found
No related tags found
1 merge request!180Add dark overview
...@@ -3,6 +3,7 @@ import glob ...@@ -3,6 +3,7 @@ import glob
import os import os
import sqlite3 import sqlite3
from collections import OrderedDict from collections import OrderedDict
from datetime import datetime, timezone
from http.server import BaseHTTPRequestHandler, HTTPServer from http.server import BaseHTTPRequestHandler, HTTPServer
from subprocess import check_output from subprocess import check_output
from uuid import uuid4 from uuid import uuid4
...@@ -158,6 +159,45 @@ class RequestHandler(BaseHTTPRequestHandler): ...@@ -158,6 +159,45 @@ class RequestHandler(BaseHTTPRequestHandler):
self.wfile.write(bytes(message, "utf8")) self.wfile.write(bytes(message, "utf8"))
return return
if "dark?" in self.path:
# Send headers
self.send_header('Content-type', 'text/html')
self.end_headers()
host = config["server-config"]["host"]
port = config["server-config"]["port"]
reports = {}
for instrument, detectors in cal_config['dark'].items():
reports[instrument] = {}
for detector in detectors:
det_inset = detector.replace('-', '_')
tmpl = '/gpfs/exfel/exp/{}/*/*/usr/dark/*/{}'.format(
instrument, det_inset)
files = glob.glob(tmpl + '/*pdf')
files += glob.glob(tmpl + '/*/*pdf')
files.sort(key=os.path.getmtime)
file_info = []
for i, file in enumerate(files):
if 'xfel.pdf' in file:
continue
if (i % 2) == 0:
bgcolor = 'EEEEEE'
else:
bgcolor = 'FFFFFF'
time = os.stat(file).st_mtime
d_time = datetime.fromtimestamp(time).replace(
tzinfo=timezone.utc)
s_time = d_time.strftime('%y-%m-%d %H:%M')
file_info.append([file, s_time, bgcolor])
reports[instrument][detector] = file_info
tmpl = Template(self.templates["dark-overview"])
message = tmpl.render(reports=reports, host=host, port=port)
self.wfile.write(bytes(message, "utf8"))
return
# Send headers # Send headers
self.send_header('Content-type', 'text/html') self.send_header('Content-type', 'text/html')
self.end_headers() self.end_headers()
......
...@@ -6,6 +6,7 @@ templates: ...@@ -6,6 +6,7 @@ templates:
running-jobs: ./templates/running_jobs.html running-jobs: ./templates/running_jobs.html
request-dark: ./templates/request_dark.html request-dark: ./templates/request_dark.html
checkbox: ./templates/checkbox.html checkbox: ./templates/checkbox.html
dark-overview: ./templates/dark_overview.html
css: ./templates/serve_overview.css css: ./templates/serve_overview.css
shell-commands: shell-commands:
...@@ -49,4 +50,4 @@ server-config: ...@@ -49,4 +50,4 @@ server-config:
web-service: web-service:
job-db: ./webservice_jobs.sqlite job-db: ./webservice_jobs.sqlite
cal-config: /home/karnem/myscratch/calibration3/calibration_configurations/default.yaml cal-config: /home/karnem/myscratch/calibration3/calibration_configurations/default.yaml
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="serve_overview.css">
<title>Overview of dark runs</title>
</head>
<body>
<div class="block">
<h1>Dark runs</h1>
{% for instrument, detectors in reports.items() %}
<h2>{{ instrument }}</h2>
{% for detector, files in detectors.items() %}
<h3>{{ detector }}</h3>
<table>
{% for file in files %}
<tr bgcolor="{{ file[2] }}">
<td> <a href=http://{{host}}:{{port}}/file?{{ file[0] }} target="_blank">{{ file[0] }}</a> </td>
<td> {{ file[1] }} </td>
</tr>
{% endfor %}
</table>
<br>
{% endfor %}
<br>
{% endfor %}
</div>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment