Mercurial > treepkg
comparison recipes/gnupg/gnupg2.py @ 156:27e78096a3fe
gnupg2 recipe: format the PKITS log as a HTML table
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Wed, 11 Jun 2008 09:48:57 +0000 |
parents | 2c942b75b98b |
children | 13de20d2db9f |
comparison
equal
deleted
inserted
replaced
155:236e91be522c | 156:27e78096a3fe |
---|---|
10 import os | 10 import os |
11 import shutil | 11 import shutil |
12 import logging | 12 import logging |
13 import re | 13 import re |
14 | 14 |
15 from genshi.template import TemplateLoader | |
16 | |
15 import treepkg.packager | 17 import treepkg.packager |
16 import treepkg.util | 18 import treepkg.util |
19 import treepkg.report | |
17 | 20 |
18 import base | 21 import base |
19 base.define_gnupg_packager("gnupg2") | 22 base.define_gnupg_packager("gnupg2") |
20 | 23 |
21 | 24 |
60 testlog.append(line) | 63 testlog.append(line) |
61 else: | 64 else: |
62 logging.info("Could not find PKITS LOG in %s", self.logfile) | 65 logging.info("Could not find PKITS LOG in %s", self.logfile) |
63 return | 66 return |
64 treepkg.util.ensure_directory(os.path.dirname(self.pkits_log)) | 67 treepkg.util.ensure_directory(os.path.dirname(self.pkits_log)) |
65 outfile = open(self.pkits_log, "w") | 68 treepkg.util.writefile(self.pkits_log, |
66 outfile.writelines(testlog) | 69 self.htmlize_pkits_log(testlog)) |
67 outfile.close() | 70 |
71 def htmlize_pkits_log(self, raw_lines): | |
72 loader = TemplateLoader([os.path.dirname(__file__)]) | |
73 template = loader.load("pkits.html") | |
74 pkits = treepkg.report.struct(revision=self.parent.revision, | |
75 lines=raw_lines) | |
76 stream = template.generate(pkits=pkits) | |
77 return stream.render('html') | |
68 | 78 |
69 | 79 |
70 class RevisionPackager(treepkg.packager.RevisionPackager): | 80 class RevisionPackager(treepkg.packager.RevisionPackager): |
71 | 81 |
72 source_packager_cls = SourcePackager | 82 source_packager_cls = SourcePackager |
73 binary_packager_cls = BinaryPackager | 83 binary_packager_cls = BinaryPackager |
74 | 84 |
75 pkits_log = treepkg.packager._filenameproperty("pkits_log.txt", | 85 pkits_log = treepkg.packager._filenameproperty("pkits_log.html", |
76 dir_attr="log_dir") | 86 dir_attr="log_dir") |
77 | 87 |
78 def list_log_files(self): | 88 def list_log_files(self): |
79 files = super(RevisionPackager, self).list_log_files() | 89 files = super(RevisionPackager, self).list_log_files() |
80 if os.path.exists(self.pkits_log): | 90 if os.path.exists(self.pkits_log): |