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
=== modified file 'lib/canonical/buildd/generate-translation-templates'
--- lib/canonical/buildd/generate-translation-templates 2010-03-12 08:32:39 +0000
+++ lib/canonical/buildd/generate-translation-templates 2010-05-19 15:34:37 +0000
@@ -36,21 +36,31 @@
36BUILD_CHROOT="$HOME/build-$BUILDID/chroot-autobuild"36BUILD_CHROOT="$HOME/build-$BUILDID/chroot-autobuild"
37USER=$(whoami)37USER=$(whoami)
3838
39# Debug output.
40echo "Running as $USER for build $BUILDID on $BRANCH_URL."
41echo "Results expected in $RESULT_NAME."
42
39BUILDD_PACKAGE=canonical/buildd43BUILDD_PACKAGE=canonical/buildd
40POTTERY=$BUILDD_PACKAGE/pottery44POTTERY=$BUILDD_PACKAGE/pottery
41# The script should be smarter about detecting the python version.45# The script should be smarter about detecting the python version.
42PYMODULES=/usr/lib/pymodules/python2.646PYMODULES=/usr/lib/pymodules/python2.6
47echo -n "Default Python in the chroot is: "
48$BUILD_CHROOT/usr/bin/python --version
4349
44GENERATE_SCRIPT=$PYMODULES/$POTTERY/generate_translation_templates.py50GENERATE_SCRIPT=$PYMODULES/$POTTERY/generate_translation_templates.py
4551
52debug_exec() {
53 echo "Executing '$1'..."
54 $1 || echo "Got error $? from '$1'."
55}
56
46# Copy pottery files to chroot.57# Copy pottery files to chroot.
47$SUDO $MKDIR -p $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE58debug_exec "$SUDO $MKDIR -vp $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE"
48$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/__init__.py59debug_exec "$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/__init__.py"
49$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/buildd/__init__.py60debug_exec "$SUDO $TOUCH $BUILD_CHROOT$PYMODULES/canonical/buildd/__init__.py"
50$SUDO $CP -r $BUILDD_HOME/$POTTERY $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE61debug_exec "$SUDO $CP -vr $BUILDD_HOME/$POTTERY $BUILD_CHROOT$PYMODULES/$BUILDD_PACKAGE"
51$SUDO $CHMOD -R go+rX $BUILD_CHROOT$PYMODULES/canonical62debug_exec "$SUDO $CHMOD -v -R go+rX $BUILD_CHROOT$PYMODULES/canonical"
52$SUDO $CHMOD 755 $BUILD_CHROOT$GENERATE_SCRIPT63debug_exec "$SUDO $CHMOD -v 755 $BUILD_CHROOT$GENERATE_SCRIPT"
53
5464
55# Enter chroot, switch back to unprivileged user, execute the generate script.65# Enter chroot, switch back to unprivileged user, execute the generate script.
56$SUDO $CHROOT $BUILD_CHROOT \66$SUDO $CHROOT $BUILD_CHROOT \
5767
=== modified file 'lib/canonical/buildd/pottery/generate_translation_templates.py'
--- lib/canonical/buildd/pottery/generate_translation_templates.py 2010-03-18 13:27:47 +0000
+++ lib/canonical/buildd/pottery/generate_translation_templates.py 2010-05-19 15:34:37 +0000
@@ -8,6 +8,8 @@
8import sys8import sys
9import tarfile9import tarfile
1010
11import logging
12
11from bzrlib.branch import Branch13from bzrlib.branch import Branch
12from bzrlib.export import export14from bzrlib.export import export
1315
@@ -31,15 +33,27 @@
31 self.work_dir = work_dir33 self.work_dir = work_dir
32 self.branch_spec = branch_spec34 self.branch_spec = branch_spec
33 self.result_name = result_name35 self.result_name = result_name
36 self.logger = self._setupLogger()
37
38 def _setupLogger(self):
39 """Sets up and returns a logger."""
40 logger = logging.getLogger("generate-templates")
41 logger.setLevel(logging.DEBUG)
42 ch = logging.StreamHandler()
43 ch.setLevel(logging.DEBUG)
44 logger.addHandler(ch)
45 return logger
3446
35 def _getBranch(self):47 def _getBranch(self):
36 """Set `self.branch_dir`, and check out branch if needed."""48 """Set `self.branch_dir`, and check out branch if needed."""
37 if ':' in self.branch_spec:49 if ':' in self.branch_spec:
38 # This is a branch URL. Check out the branch.50 # This is a branch URL. Check out the branch.
39 self.branch_dir = os.path.join(self.work_dir, 'source-tree')51 self.branch_dir = os.path.join(self.work_dir, 'source-tree')
52 self.logger.info("Getting remote branch %s..." % self.branch_spec)
40 self._checkout(self.branch_spec)53 self._checkout(self.branch_spec)
41 else:54 else:
42 # This is a local filesystem path. Use the branch in-place.55 # This is a local filesystem path. Use the branch in-place.
56 self.logger.info("Using local branch %s..." % self.branch_spec)
43 self.branch_dir = self.branch_spec57 self.branch_dir = self.branch_spec
4458
45 def _checkout(self, branch_url):59 def _checkout(self, branch_url):
@@ -48,24 +62,33 @@
48 The branch is checked out to the location specified by62 The branch is checked out to the location specified by
49 `self.branch_dir`.63 `self.branch_dir`.
50 """64 """
65 self.logger.info("Opening branch %s..." % branch_url)
51 branch = Branch.open(branch_url)66 branch = Branch.open(branch_url)
67 self.logger.info("Getting branch revision tree...")
52 rev_tree = branch.basis_tree()68 rev_tree = branch.basis_tree()
69 self.logger.info("Exporting branch to %s..." % self.branch_dir)
53 export(rev_tree, self.branch_dir)70 export(rev_tree, self.branch_dir)
71 self.logger.info("Exporting branch done.")
5472
55 def _makeTarball(self, files):73 def _makeTarball(self, files):
56 """Put the given files into a tarball in the working directory."""74 """Put the given files into a tarball in the working directory."""
57 tarname = os.path.join(self.work_dir, self.result_name)75 tarname = os.path.join(self.work_dir, self.result_name)
76 self.logger.info("Making tarball with templates in %s..." % tarname)
58 tarball = tarfile.open(tarname, 'w|gz')77 tarball = tarfile.open(tarname, 'w|gz')
59 files = [name for name in files if not name.endswith('/')]78 files = [name for name in files if not name.endswith('/')]
60 for path in files:79 for path in files:
61 full_path = os.path.join(self.branch_dir, path)80 full_path = os.path.join(self.branch_dir, path)
81 self.logger.info("Adding template %s..." % full_path)
62 tarball.add(full_path, path)82 tarball.add(full_path, path)
63 tarball.close()83 tarball.close()
84 self.logger.info("Tarball generated.")
6485
65 def generate(self):86 def generate(self):
66 """Do It. Generate templates."""87 """Do It. Generate templates."""
88 self.logger.info("Generating templates for %s." % self.branch_spec)
67 self._getBranch()89 self._getBranch()
68 pots = intltool.generate_pots(self.branch_dir)90 pots = intltool.generate_pots(self.branch_dir)
91 self.logger.info("Generated %d templates." % len(pots))
69 if len(pots) > 0:92 if len(pots) > 0:
70 self._makeTarball(pots)93 self._makeTarball(pots)
71 return 094 return 0