Merge lp:~jtv/launchpad/bug-723733 into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 12451
Proposed branch: lp:~jtv/launchpad/bug-723733
Merge into: lp:launchpad
Diff against target: 72 lines (+13/-11)
1 file modified
lib/devscripts/ec2test/builtins.py (+13/-11)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-723733
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+50935@code.launchpad.net

Commit message

[r=abentley][no-qa][bug=723733] Clear LC_TIME for update-image.

Description of the change

= Summary =

To update the AMI image, as per https://dev.launchpad.net/EC2Test/Image, it's best to set LC_TIME to some known value because some users (including at least Julian) have run into problems when their personal settings weren't handled well by the image. This makes for an ugly workaround.

== Proposed fix ==

The code for "ec2 update-image" already clears the LC_ALL and LANG variables for the same reason. It should drop LC_TIME as well.

== Pre-implementation notes ==

Julian agrees.

== Implementation details ==

I also encapsulated various pdb.set_trace() calls into a single method. Each of those calls was reported as lint, and now there's only one left. Not perfect, but perhaps better than suppressing warnings and repeating the same iffy pattern all over the place.

The function's name looks a little unusual, but I think best says "call set_trace if this variable is True" without requiring the reader to look up what it does.

== Tests ==

Ahem. All I can think of is: run the image.

== Demo and Q/A ==

Run the "ec2 update-image" command line from https://dev.launchpad.net/EC2Test/Image but with LC_TIME set to en_GB instead of en_US.UTF-8.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/devscripts/ec2test/builtins.py

./lib/devscripts/ec2test/builtins.py
     153: Line contains a call to pdb.

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/devscripts/ec2test/builtins.py'
2--- lib/devscripts/ec2test/builtins.py 2010-11-29 21:32:06 +0000
3+++ lib/devscripts/ec2test/builtins.py 2011-02-23 14:49:57 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """The command classes for the 'ec2' utility."""
10@@ -147,6 +147,12 @@
11 return filename
12
13
14+def set_trace_if(enable_debugger=False):
15+ """If `enable_debugger` is True, drop into the debugger."""
16+ if enable_debugger:
17+ pdb.set_trace()
18+
19+
20 class EC2Command(Command):
21 """Subclass of `Command` that customizes usage to say 'ec2' not 'bzr'.
22
23@@ -272,8 +278,7 @@
24 pqm_submit_location=None, pqm_email=None, postmortem=False,
25 attached=False, debug=False, open_browser=False,
26 include_download_cache_changes=False):
27- if debug:
28- pdb.set_trace()
29+ set_trace_if(debug)
30 if branch is None:
31 branch = []
32 branches, test_branch = _get_branches_and_test_branch(
33@@ -387,8 +392,7 @@
34 "wide because this will break the rest of Launchpad.\n\n"
35 "***************************************************\n")
36 raise
37- if debug:
38- pdb.set_trace()
39+ set_trace_if(debug)
40 if print_commit and dry_run:
41 raise BzrCommandError(
42 "Cannot specify --print-commit and --dry-run.")
43@@ -482,8 +486,7 @@
44 def run(self, test_branch=None, branch=None, trunk=False, machine=None,
45 instance_type=DEFAULT_INSTANCE_TYPE, debug=False,
46 include_download_cache_changes=False, demo=None):
47- if debug:
48- pdb.set_trace()
49+ set_trace_if(debug)
50 if branch is None:
51 branch = []
52 branches, test_branch = _get_branches_and_test_branch(
53@@ -558,8 +561,7 @@
54 def run(self, ami_name, machine=None, instance_type='m1.large',
55 debug=False, postmortem=False, extra_update_image_command=None,
56 public=False):
57- if debug:
58- pdb.set_trace()
59+ set_trace_if(debug)
60
61 if extra_update_image_command is None:
62 extra_update_image_command = []
63@@ -568,8 +570,8 @@
64 # fresh Ubuntu images and cause havoc if the locales they refer to are
65 # not available. We kill them here to ease bootstrapping, then we
66 # later modify the image to prevent sshd from accepting them.
67- os.environ.pop("LANG", None)
68- os.environ.pop("LC_ALL", None)
69+ for variable in ['LANG', 'LC_ALL', 'LC_TIME']:
70+ os.environ.pop(variable, None)
71
72 credentials = EC2Credentials.load_from_file()
73