Merge lp:~danilo/launchpad/bug-580345-devel into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Approved by: Данило Шеган
Approved revision: no longer in the source branch.
Merged at revision: 10894
Proposed branch: lp:~danilo/launchpad/bug-580345-devel
Merge into: lp:launchpad
Diff against target: 117 lines (+40/-7)
2 files modified
lib/canonical/buildd/generate-translation-templates (+17/-7)
lib/canonical/buildd/pottery/generate_translation_templates.py (+23/-0)
To merge this branch: bzr merge lp:~danilo/launchpad/bug-580345-devel
Reviewer Review Type Date Requested Status
Henning Eggers (community) code Approve
Review via email: mp+25597@code.launchpad.net

Commit message

Add more logging to generate-translation-templates scripts that run on the build slaves.

Description of the change

= Bug 580345 =

At the moment, we have very terse build job debug output. Considering how build farm (or at least translation jobs on it) works in such a way that we lose the log after a job completes, we should at least have an option of better output during build time (which we can track on launchpad.net/builders).

After this branch lands, we need to prepare another canonical-buildd package and roll it out to build slaves (only LaMont can do it).

== Tests ==

 bin/test -vvct translationtemplates

== QA ==

QAd on dogfood (rubidium slave) by following https://dev.launchpad.net/Translations/GenerateTemplatesOnTestServers

To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

Thanks for adding this!

<henninge> danilos: wasn't there some problem with 'debug_exec', too?
<danilos> henninge, it's fixed (original branch was against production-devel, but that doesn't make any difference for build slaves)
<danilos> henninge, I had a bashism ("function debug_func {" instead of "debug_func()" which works everywhere)
* deryck hat die Verbindung getrennt (Quit: Leaving)
<henninge> danilos: ah yes, I see.
<henninge> danilos: the python --version is pretty useless, though.
<henninge> danilos: you should use the python in the chroot. This script is still running outside of it.
<danilos> henninge, I know, but can't do that in the shell script :)
<henninge> not?
<danilos> henninge, well, chroot would first have to be set-up and that happens only at the end
<henninge> danilos: but python works from almost anywhere.
<henninge> let me try that ... ;)
<henninge> danilos: yup, works. Just do "$BUILD_CHROOT/usr/bin/python --version"
<danilos> henninge, sure

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/buildd/generate-translation-templates'
2--- lib/canonical/buildd/generate-translation-templates 2010-03-12 08:32:39 +0000
3+++ lib/canonical/buildd/generate-translation-templates 2010-05-19 15:34:37 +0000
4@@ -36,21 +36,31 @@
5 BUILD_CHROOT="$HOME/build-$BUILDID/chroot-autobuild"
6 USER=$(whoami)
7
8+# Debug output.
9+echo "Running as $USER for build $BUILDID on $BRANCH_URL."
10+echo "Results expected in $RESULT_NAME."
11+
12 BUILDD_PACKAGE=canonical/buildd
13 POTTERY=$BUILDD_PACKAGE/pottery
14 # The script should be smarter about detecting the python version.
15 PYMODULES=/usr/lib/pymodules/python2.6
16+echo -n "Default Python in the chroot is: "
17+$BUILD_CHROOT/usr/bin/python --version
18
19 GENERATE_SCRIPT=$PYMODULES/$POTTERY/generate_translation_templates.py
20
21+debug_exec() {
22+ echo "Executing '$1'..."
23+ $1 || echo "Got error $? from '$1'."
24+}
25+
26 # Copy pottery files to chroot.
27-$SUDO $MKDIR -p $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE
28-$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/__init__.py
29-$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/buildd/__init__.py
30-$SUDO $CP -r $BUILDD_HOME/$POTTERY $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE
31-$SUDO $CHMOD -R go+rX $BUILD_CHROOT$PYMODULES/canonical
32-$SUDO $CHMOD 755 $BUILD_CHROOT$GENERATE_SCRIPT
33-
34+debug_exec "$SUDO $MKDIR -vp $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE"
35+debug_exec "$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/__init__.py"
36+debug_exec "$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/buildd/__init__.py"
37+debug_exec "$SUDO $CP -vr $BUILDD_HOME/$POTTERY $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE"
38+debug_exec "$SUDO $CHMOD -v -R go+rX $BUILD_CHROOT$PYMODULES/canonical"
39+debug_exec "$SUDO $CHMOD -v 755 $BUILD_CHROOT$GENERATE_SCRIPT"
40
41 # Enter chroot, switch back to unprivileged user, execute the generate script.
42 $SUDO $CHROOT $BUILD_CHROOT \
43
44=== modified file 'lib/canonical/buildd/pottery/generate_translation_templates.py'
45--- lib/canonical/buildd/pottery/generate_translation_templates.py 2010-03-18 13:27:47 +0000
46+++ lib/canonical/buildd/pottery/generate_translation_templates.py 2010-05-19 15:34:37 +0000
47@@ -8,6 +8,8 @@
48 import sys
49 import tarfile
50
51+import logging
52+
53 from bzrlib.branch import Branch
54 from bzrlib.export import export
55
56@@ -31,15 +33,27 @@
57 self.work_dir = work_dir
58 self.branch_spec = branch_spec
59 self.result_name = result_name
60+ self.logger = self._setupLogger()
61+
62+ def _setupLogger(self):
63+ """Sets up and returns a logger."""
64+ logger = logging.getLogger("generate-templates")
65+ logger.setLevel(logging.DEBUG)
66+ ch = logging.StreamHandler()
67+ ch.setLevel(logging.DEBUG)
68+ logger.addHandler(ch)
69+ return logger
70
71 def _getBranch(self):
72 """Set `self.branch_dir`, and check out branch if needed."""
73 if ':' in self.branch_spec:
74 # This is a branch URL. Check out the branch.
75 self.branch_dir = os.path.join(self.work_dir, 'source-tree')
76+ self.logger.info("Getting remote branch %s..." % self.branch_spec)
77 self._checkout(self.branch_spec)
78 else:
79 # This is a local filesystem path. Use the branch in-place.
80+ self.logger.info("Using local branch %s..." % self.branch_spec)
81 self.branch_dir = self.branch_spec
82
83 def _checkout(self, branch_url):
84@@ -48,24 +62,33 @@
85 The branch is checked out to the location specified by
86 `self.branch_dir`.
87 """
88+ self.logger.info("Opening branch %s..." % branch_url)
89 branch = Branch.open(branch_url)
90+ self.logger.info("Getting branch revision tree...")
91 rev_tree = branch.basis_tree()
92+ self.logger.info("Exporting branch to %s..." % self.branch_dir)
93 export(rev_tree, self.branch_dir)
94+ self.logger.info("Exporting branch done.")
95
96 def _makeTarball(self, files):
97 """Put the given files into a tarball in the working directory."""
98 tarname = os.path.join(self.work_dir, self.result_name)
99+ self.logger.info("Making tarball with templates in %s..." % tarname)
100 tarball = tarfile.open(tarname, 'w|gz')
101 files = [name for name in files if not name.endswith('/')]
102 for path in files:
103 full_path = os.path.join(self.branch_dir, path)
104+ self.logger.info("Adding template %s..." % full_path)
105 tarball.add(full_path, path)
106 tarball.close()
107+ self.logger.info("Tarball generated.")
108
109 def generate(self):
110 """Do It. Generate templates."""
111+ self.logger.info("Generating templates for %s." % self.branch_spec)
112 self._getBranch()
113 pots = intltool.generate_pots(self.branch_dir)
114+ self.logger.info("Generated %d templates." % len(pots))
115 if len(pots) > 0:
116 self._makeTarball(pots)
117 return 0