Merge lp:~barry/ubuntu-archive-tools/exit-status into lp:ubuntu-archive-tools

Proposed by Barry Warsaw on 2015-08-07
Status: Merged
Merged at revision: 969
Proposed branch: lp:~barry/ubuntu-archive-tools/exit-status
Merge into: lp:ubuntu-archive-tools
Diff against target: 34 lines (+16/-1)
1 file modified
copy-package (+16/-1)
To merge this branch: bzr merge lp:~barry/ubuntu-archive-tools/exit-status
Reviewer Review Type Date Requested Status
Adam Conrad 2015-08-07 Approve on 2015-08-07
Review via email: mp+267385@code.launchpad.net

Description of the Change

When the source can't be found, print the exception and continue unless the new option --fail-immediately is given, in which case False is returned to force a non-zero exit status.

To post a comment you must log in.
970. By Barry Warsaw on 2015-08-07

Improve the error handling, and restore the sense that if the package is
missing, exit with status 1. Change --fail-immediately to --skip-missing
which ignores any missing packages and exits with status 0.

971. By Barry Warsaw on 2015-08-07

Always print the error.

Adam Conrad (adconrad) wrote :

LGTM:

(base)adconrad@nosferatu:~/build/ubuntu-archive-tools$ copy-package --from=ppa:adconrad/ubuntu/ppa --to=ppa:adconrad/ubuntu/ppa -s trusty gerbafl
Copy candidates:
Could not find source 'gerbafl/None' in trusty
(base)adconrad@nosferatu:~/build/ubuntu-archive-tools$ echo $?
1
(base)adconrad@nosferatu:~/build/ubuntu-archive-tools$ copy-package --from=ppa:adconrad/ubuntu/ppa --to=ppa:adconrad/ubuntu/ppa --skip-missing -s trusty gerbafl
Copy candidates:
Could not find source 'gerbafl/None' in trusty
Skipping
(base)adconrad@nosferatu:~/build/ubuntu-archive-tools$ echo $?
0

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'copy-package'
2--- copy-package 2014-11-12 14:37:16 +0000
3+++ copy-package 2015-08-07 21:43:05 +0000
4@@ -48,7 +48,16 @@
5 for package in packages:
6 print("Copy candidates:")
7
8- source = lputils.find_latest_published_source(options, package)
9+ try:
10+ source = lputils.find_latest_published_source(options, package)
11+ except lputils.PackageMissing as error:
12+ print(error)
13+ if options.skip_missing:
14+ print('Skipping')
15+ continue
16+ else:
17+ # Bail with exit code non-zero.
18+ return False
19 print("\t%s" % source.display_name)
20 num_copies = 1
21
22@@ -154,6 +163,12 @@
23 help=(
24 "force copy when source == destination (e.g. when reverting to "
25 "a previous version in the same suite)"))
26+ parser.add_option(
27+ "--skip-missing", default=False, action="store_true",
28+ help=(
29+ "When a package cannot be copied, normally this script exits "
30+ "with a non-zero status. With --skip-missing instead, the "
31+ "error is printed and copying continues"))
32 options, args = parser.parse_args()
33
34 options.launchpad = Launchpad.login_with(

Subscribers

People subscribed via source and target branches