]>
Commit | Line | Data |
---|---|---|
dfff8bd5 MM |
1 | # vi: encoding=utf-8 ts=8 sts=4 sw=4 et |
2 | ||
c8782384 | 3 | import path |
266bcdd3 | 4 | import time |
c8782384 | 5 | import os |
7bf8de49 | 6 | import re |
97c76301 | 7 | import log |
c8782384 MM |
8 | |
9 | from config import config | |
bdc3292c | 10 | import util |
c8782384 MM |
11 | |
12 | class Buildlogs_Queue: | |
dfff8bd5 MM |
13 | def __init__(self): |
14 | self.queue = [] | |
15 | self.some_failed = 0 | |
16bc8b6f | 16 | self.requester_email = None |
dfff8bd5 MM |
17 | |
18 | def init(self, g): | |
19 | self.requester_email = g.requester_email | |
20 | ||
5c59479b | 21 | def add(self, logfile, failed, id): |
dfff8bd5 MM |
22 | # if /dev/null, don't even bother to store it |
23 | if config.buildlogs_url == "/dev/null": | |
24 | return | |
76ba3bb3 | 25 | name = re.sub(r"\.spec\.log", "", os.path.basename(logfile)) + "," + id + ".bz2" |
97c76301 | 26 | ret = os.system("bzip2 --best --force < %s > %s" \ |
9be34149 | 27 | % (logfile, path.buildlogs_queue_dir + '/' + id)) |
97c76301 AM |
28 | if ret: |
29 | log.error("bzip2 compression of %s failed; does bzip2 binary exist?" % (logfile)) | |
dfff8bd5 MM |
30 | |
31 | if failed: s = "FAIL" | |
32 | else: s = "OK" | |
9be34149 | 33 | f = open(path.buildlogs_queue_dir + '/' + id + ".info", "w") |
dfff8bd5 MM |
34 | f.write("Status: %s\nEND\n" % s) |
35 | f.close() | |
36 | ||
37 | self.queue.append({'name': name, 'id': id, 'failed': failed}) | |
38 | ||
39 | def flush(self): | |
40 | def desc(l): | |
76ba3bb3 | 41 | return """Target: %s/%s |
266bcdd3 | 42 | Builder: %s |
266bcdd3 | 43 | Time: %d |
1051562e | 44 | Type: buildlog |
266bcdd3 MM |
45 | Requester: %s |
46 | END | |
76ba3bb3 | 47 | """ % (config.buildlogs_url, l['name'], config.builder, time.time(), self.requester_email) |
dfff8bd5 MM |
48 | |
49 | for l in self.queue: | |
9246c3cb | 50 | f = open(path.buildlogs_queue_dir + '/' + l['id'] + ".desc.tmp", "w") |
dfff8bd5 MM |
51 | f.write(desc(l)) |
52 | f.close() | |
9246c3cb | 53 | os.rename(path.buildlogs_queue_dir + '/' + l['id'] + ".desc.tmp", path.buildlogs_queue_dir + '/' + l['id'] + ".desc") |
c8782384 MM |
54 | |
55 | queue = Buildlogs_Queue() | |
b5a39692 | 56 | |
e2cad913 | 57 | def init(r): |
dfff8bd5 | 58 | queue.init(r) |
e2cad913 | 59 | |
580391bc | 60 | def add(logfile, failed, id): |
dfff8bd5 | 61 | "Add new buildlog with specified status." |
580391bc | 62 | queue.add(logfile, failed, id) |
b5a39692 | 63 | |
2e33eed1 | 64 | def flush(): |
dfff8bd5 MM |
65 | "Send buildlogs to server." |
66 | queue.flush() |