annotate scripts/build.py @ 409:5786700df0c7

Moved/restructured the modules implementing report chart generators and report summarizers.
author cmlenz
date Tue, 07 Aug 2007 09:17:30 +0000
parents 933105ab516b
children
rev   line source
0
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
1 #!/usr/bin/env python
379
0df178e07fdb Use UTF-8 as encoding of source files.
cmlenz
parents: 245
diff changeset
2 # -*- coding: utf-8 -*-
5
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
3 #
408
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 379
diff changeset
4 # Copyright (C) 2005-2007 Christopher Lenz <cmlenz@gmx.de>
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 379
diff changeset
5 # Copyright (C) 2007 Edgewall Software
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 153
diff changeset
6 # All rights reserved.
5
738a0ae251f6 Added GPL boilerplate.
cmlenz
parents: 4
diff changeset
7 #
163
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 153
diff changeset
8 # This software is licensed as described in the file COPYING, which
634be6cbb808 Flip the switch: Bitten is now BSD-licensed.
cmlenz
parents: 153
diff changeset
9 # you should have received as part of this distribution. The terms
408
933105ab516b Update file headers and other stuff pointing to the old home.
cmlenz
parents: 379
diff changeset
10 # are also available at http://bitten.edgewall.org/wiki/License.
0
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
11
103
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
12 import itertools
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
13 import logging
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
14 import sys
0
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
15
61
47ab019508dd Moved {{{BuildError}}} class into package {{{bitten.build}}}.
cmlenz
parents: 60
diff changeset
16 from bitten.build import BuildError
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
17 from bitten.recipe import Recipe
148
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
18 from bitten.util import xmlio
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
19
103
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
20 def main():
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
21 from bitten import __version__ as VERSION
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
22 from optparse import OptionParser
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
23
103
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
24 parser = OptionParser(usage='usage: %prog [options] [step1] [step2] ...',
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
25 version='%%prog %s' % VERSION)
148
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
26 parser.add_option('-f', '--recipe-file', action='store', dest='recipe_file',
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
27 metavar='FILE', help='read build recipe from FILE')
240
24e91cbae6e0 New recipe command `<java:ant>` for running Ant builds.
cmlenz
parents: 203
diff changeset
28 parser.add_option('--print-logs', action='store_const',
24e91cbae6e0 New recipe command `<java:ant>` for running Ant builds.
cmlenz
parents: 203
diff changeset
29 dest='print_logs', const=True,
24e91cbae6e0 New recipe command `<java:ant>` for running Ant builds.
cmlenz
parents: 203
diff changeset
30 help='print build logs')
144
76dea27af878 * Make the `<python:unittest>` command strip the base dir from file names in the report. Fixes #42.
cmlenz
parents: 131
diff changeset
31 parser.add_option('--print-reports', action='store_const',
76dea27af878 * Make the `<python:unittest>` command strip the base dir from file names in the report. Fixes #42.
cmlenz
parents: 131
diff changeset
32 dest='print_reports', const=True,
76dea27af878 * Make the `<python:unittest>` command strip the base dir from file names in the report. Fixes #42.
cmlenz
parents: 131
diff changeset
33 help='print generated reports')
103
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
34 parser.add_option('-v', '--verbose', action='store_const', dest='loglevel',
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
35 const=logging.DEBUG, help='print as much as possible')
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
36 parser.add_option('-q', '--quiet', action='store_const', dest='loglevel',
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
37 const=logging.ERROR, help='print as little as possible')
148
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
38 parser.set_defaults(loglevel=logging.INFO, recipe_file='recipe.xml')
103
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
39 options, args = parser.parse_args()
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
40
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
41 log = logging.getLogger('bitten')
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
42 log.setLevel(options.loglevel)
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
43 handler = logging.StreamHandler()
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
44 handler.setLevel(options.loglevel)
109
5bf22bb87915 Transmit build log and generated data back to the build master in XML format. Closes #23.
cmlenz
parents: 103
diff changeset
45 formatter = logging.Formatter('%(message)s')
103
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
46 handler.setFormatter(formatter)
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
47 log.addHandler(handler)
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
48
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
49 steps_to_run = dict([(step, False) for step in args])
148
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
50
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
51 recipe_file = file(options.recipe_file, 'r')
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
52 try:
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
53 recipe = Recipe(xmlio.parse(recipe_file))
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
54 for step in recipe:
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
55 if not steps_to_run or step.id in steps_to_run:
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
56 print
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 148
diff changeset
57 print '-->', step.id
203
e6ddca1e5712 Huge refactoring to remove dependency on BDB XML. Report data is now stored in the Trac database (SQLite/PostgreSQL).
cmlenz
parents: 163
diff changeset
58 for type, category, generator, output in step.execute(recipe.ctxt):
148
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
59 if type == Recipe.ERROR:
245
a22ec8fce6c9 Store the reason(s) for build step failure in the database.
cmlenz
parents: 240
diff changeset
60 log.error(output)
240
24e91cbae6e0 New recipe command `<java:ant>` for running Ant builds.
cmlenz
parents: 203
diff changeset
61 elif type == Recipe.LOG and options.print_logs:
24e91cbae6e0 New recipe command `<java:ant>` for running Ant builds.
cmlenz
parents: 203
diff changeset
62 output.write(sys.stdout, newlines=True)
148
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
63 elif type == Recipe.REPORT and options.print_reports:
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
64 output.write(sys.stdout, newlines=True)
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
65 if step.id in steps_to_run:
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
66 steps_to_run[step.id] = True
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
67 finally:
f3f5895e373c Fixes to problems in recipe handling introduced in [155].
cmlenz
parents: 144
diff changeset
68 recipe_file.close()
0
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
69
0b2a3581c48d Import initial ''bitten'' source.
cmlenz
parents:
diff changeset
70 if __name__ == '__main__':
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
71 try:
103
f1baf05a49dd * Strip extra line separators from recipe command output on windows. Closes #25.
cmlenz
parents: 72
diff changeset
72 main()
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
73 except BuildError, e:
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 148
diff changeset
74 print
8
45d7bfe64d00 Slightly improved implementation of the python tools.
cmlenz
parents: 5
diff changeset
75 print>>sys.stderr, 'FAILED: %s' % e
4
196009657e5e Simplify the recipe commands interface:
cmlenz
parents: 3
diff changeset
76 sys.exit(-1)
153
3ab91c56d7bc * Fix `pythontools` unit tests on windows.
cmlenz
parents: 148
diff changeset
77 print
8
45d7bfe64d00 Slightly improved implementation of the python tools.
cmlenz
parents: 5
diff changeset
78 print 'SUCCESS'
Copyright (C) 2012-2017 Edgewall Software