Merge lp:~ian-clatworthy/bzr-builder/minor-code-cleanups into lp:~james-w/bzr-builder/trunk-old

Proposed by Ian Clatworthy
Status: Merged
Merge reported by: James Westby
Merged at revision: not available
Proposed branch: lp:~ian-clatworthy/bzr-builder/minor-code-cleanups
Merge into: lp:~james-w/bzr-builder/trunk-old
Diff against target: 119 lines (+35/-35)
1 file modified
__init__.py (+35/-35)
To merge this branch: bzr merge lp:~ian-clatworthy/bzr-builder/minor-code-cleanups
Reviewer Review Type Date Requested Status
James Westby Needs Fixing
Robert Collins (community) Approve
Review via email: mp+15140@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Some fly-by code clean-ups in __init__.py. Nothing controversial hopefully.

Revision history for this message
Robert Collins (lifeless) wrote :

Looks good to me (though it will conflict with ~lifeless/bzr-builder/blocking).

review: Approve
Revision history for this message
James Westby (james-w) wrote :

Hi,

Thanks for working on this.

8 +# The default distribution used by get_changelog_entry()
9 +DEFAULT_UBUNTU_DISTRIBUTION = "jaunty"

Doing this makes it clear that this should be "lucid" now.

38 +def run_command(command, msg, error_msg):

69 + _run_command(command,

86 + _run_command(command,

103 + _run_command(command,

These should match shouldn't they?

53 + raise errors.BzrCommandError("%s: %s" % (output, error_msg))

Aren't output and error_msg the wrong way round?

Thanks,

James

review: Needs Fixing
56. By Ian Clatworthy

Corrections from James' review feedback

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

> 8 +# The default distribution used by get_changelog_entry()
> 9 +DEFAULT_UBUNTU_DISTRIBUTION = "jaunty"
>
> Doing this makes it clear that this should be "lucid" now.

Fixed.

> 38 +def run_command(command, msg, error_msg):
>
> 69 + _run_command(command,
>
> 86 + _run_command(command,
>
> 103 + _run_command(command,
>
> These should match shouldn't they?

Fixed.

> 53 + raise errors.BzrCommandError("%s: %s" % (output, error_msg))
>
> Aren't output and error_msg the wrong way round?

Oops. Fixed now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2009-11-23 16:42:00 +0000
3+++ __init__.py 2009-11-25 02:20:24 +0000
4@@ -151,6 +151,10 @@
5 )
6
7
8+# The default distribution used by add_changelog_entry()
9+DEFAULT_UBUNTU_DISTRIBUTION = "lucid"
10+
11+
12 def write_manifest_to_path(path, base_branch):
13 parent_dir = os.path.dirname(path)
14 if parent_dir != '' and not os.path.exists(parent_dir):
15@@ -188,8 +192,7 @@
16
17
18 def get_maintainer():
19- """
20- Create maintainer string using the same algorithm as in dch
21+ """Create maintainer string using the same algorithm as in dch.
22 """
23 env = os.environ
24 regex = re.compile(r"^(.*)\s+<(.*)>$")
25@@ -278,7 +281,7 @@
26 "take the package name from, and --package not "
27 "specified.")
28 if distribution is None:
29- distribution = "jaunty"
30+ distribution = DEFAULT_UBUNTU_DISTRIBUTION
31 # Use debian packaging environment variables
32 # or default values if they don't exist
33 author = "%s <%s>" % get_maintainer()
34@@ -295,47 +298,44 @@
35 cl_f.close()
36
37
38+def _run_command(command, msg, error_msg):
39+ """ Run a command in a subprocess.
40+
41+ :param command: list with command and parameters
42+ :param msg: message to display to the user
43+ :param error_msg: message to display if something fails.
44+ """
45+ trace.note(msg)
46+ proc = subprocess.Popen(command, cwd=basedir,
47+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
48+ stdin=subprocess.PIPE)
49+ proc.stdin.close()
50+ retcode = proc.wait()
51+ if retcode != 0:
52+ output = proc.stdout.read()
53+ raise errors.BzrCommandError("%s: %s" % (error_msg, output))
54+
55+
56 def build_source_package(basedir):
57- trace.note("Building the source package")
58 command = ["/usr/bin/debuild", "--no-tgz-check", "-i", "-I", "-S",
59 "-uc", "-us"]
60- proc = subprocess.Popen(command, cwd=basedir,
61- stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
62- stdin=subprocess.PIPE)
63- proc.stdin.close()
64- retcode = proc.wait()
65- if retcode != 0:
66- output = proc.stdout.read()
67- raise errors.BzrCommandError("Failed to build the source package: "
68- "%s" % output)
69+ _run_command(command,
70+ "Building the source package",
71+ "Failed to build the source package")
72
73
74 def sign_source_package(basedir, key_id):
75- trace.note("Signing the source package")
76 command = ["/usr/bin/debsign", "-S", "-k%s" % key_id]
77- proc = subprocess.Popen(command, cwd=basedir,
78- stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
79- stdin=subprocess.PIPE)
80- proc.stdin.close()
81- retcode = proc.wait()
82- if retcode != 0:
83- output = proc.stdout.read()
84- raise errors.BzrCommandError("Signing the package failed: "
85- "%s" % output)
86+ _run_command(command,
87+ "Signing the source package",
88+ "Signing the package failed")
89
90
91 def dput_source_package(basedir, target):
92- trace.note("Uploading the source package")
93 command = ["/usr/bin/debrelease", "-S", "--dput", target]
94- proc = subprocess.Popen(command, cwd=basedir,
95- stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
96- stdin=subprocess.PIPE)
97- proc.stdin.close()
98- retcode = proc.wait()
99- if retcode != 0:
100- output = proc.stdout.read()
101- raise errors.BzrCommandError("Uploading the package failed: "
102- "%s" % output)
103+ _run_command(command,
104+ "Uploading the source package",
105+ "Uploading the package failed")
106
107
108 def get_base_branch(recipe_file, if_changed_from=None):
109@@ -414,8 +414,8 @@
110 help="dput the built package to the specified "
111 "dput target."),
112 Option("key-id", type=str, short_name="k",
113- help="Sign the packages with the specified GnuPG key, "
114- "must be specified if you use --dput."),
115+ help="Sign the packages with the specified GnuPG key. "
116+ "Must be specified if you use --dput."),
117 ]
118
119 takes_args = ["recipe_file", "working_directory?"]

Subscribers

People subscribed via source and target branches