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