-
Notifications
You must be signed in to change notification settings - Fork 5
/
buildlogs
executable file
·61 lines (53 loc) · 2.14 KB
/
buildlogs
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
#!/usr/bin/env python26
import bottle, os, re
from os.path import exists
from bottle import route, debug, abort
from commands import getstatusoutput
from time import strptime
app = bottle.default_app()
from secrets import cern_secrets as config
debug(config["debug"])
def format(s, **kwds):
return s % kwds
BASE_AFS_DIR="/afs/cern.ch/cms/sw/ReleaseCandidates"
@route('/')
def index():
return 'Index'
def sanitize(s, ok="a-zA-Z0-9_.-"):
return re.sub("[.]/", "", re.sub("[^%s]" % ok, "", s))
@route('/<architecture>/<release>/<subsystem>/<package>')
def hello(architecture, release, subsystem, package):
return extractLogs(architecture, release, format("%(subsystem)s/%(package)s/log.html", subsystem=subsystem, package=package), "./")
DAYS=["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
@route('/<architecture>/<release>')
def listPackages(architecture, release):
return extractLogs(architecture, release, "index.html", "./" + release)
def extractLogs(architecture, release, filename, remapping):
m = re.match(".*(20[0-9][0-9]-[0-9]{2}-[0-9]{2}-[0-9]{4})$", release)
if not m:
abort(400, "Bad Request")
d = strptime(m.group(1), "%Y-%m-%d-%H%M")
m = re.match("CMSSW_([0-9]+)_([0-9]+)_.*", release)
if not m:
abort(400, "Bad Request")
queue="%s.%s" % m.groups()
archive = format("%(basedir)s/%(architecture)s/www/%(weekday)s/%(queue)s-%(weekday)s-%(hour)s/%(release)s/new/html-logs.tgz",
architecture=sanitize(architecture),
weekday=DAYS[d.tm_wday],
queue=sanitize(queue),
hour='%02i' % d.tm_hour,
release=sanitize(release),
basedir=BASE_AFS_DIR)
if not exists(archive):
abort(400, "Bad Request")
command = format("tar xOzf %(archive)s ./%(filename)s | sed -e's|http://cern.ch/cms-sdt/rc/.*/new|%(remapping)s|g;s|/log.html||g'",
archive=archive,
filename=filename,
remapping=remapping)
err, out = getstatusoutput(command)
if err:
abort(400, "Bad Request")
return out
if __name__ == '__main__':
from wsgiref.handlers import CGIHandler
CGIHandler().run(app)