Merge ~cjwatson/ubuntu-archive-tools:queue-copy-contains-build into ubuntu-archive-tools:main

Proposed by Colin Watson
Status: Merged
Merged at revision: 8fd3c6274006cab32c8f16bcbe376d38b8bca2ae
Proposed branch: ~cjwatson/ubuntu-archive-tools:queue-copy-contains-build
Merge into: ubuntu-archive-tools:main
Diff against target: 68 lines (+15/-9)
1 file modified
queue (+15/-9)
Reviewer Review Type Date Requested Status
Andy Whitcroft Approve
Review via email: mp+411067@code.launchpad.net

Commit message

queue: Add contains-build information for copies

Description of the change

Now that Launchpad exposes information on whether copies contain binaries, `queue` should take advantage of that. With this, source-only copies show "X-" as before, while source-and-binary copies show "XB".

To post a comment you must log in.
Revision history for this message
Iain Lane (laney) wrote :

wdyt about making `queue fetch` only fetch binaries if they are part of the copy? perhaps by way of an adjustment to `urls()`?

Revision history for this message
Colin Watson (cjwatson) wrote :

@laney Good idea, thanks. How's this?

Revision history for this message
Andy Whitcroft (apw) wrote :

Looks good. Engineered a copy with binaries (and without) and confirmed this differentiates in the manner you would expect.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/queue b/queue
2index d1406bd..cdde30d 100755
3--- a/queue
4+++ b/queue
5@@ -129,7 +129,7 @@ FOOT_MARGIN = " " * (9 + 6 + 1 + 22 + 1 + 22 + 2)
6
7 def make_tag(item):
8 if item.contains_copy:
9- return "X-"
10+ return "X" + ("B" if item.contains_build else "-")
11 else:
12 return (("S" if item.contains_source else "-") +
13 ("B" if item.contains_build else "-"))
14@@ -231,15 +231,17 @@ def info(options, args):
15
16 # Get librarian URLs for source_package_publishing_history or package_upload
17 # objects
18-def urls(options, item):
19+def urls(item, include_source=False, include_binary=False):
20 try:
21 if item.contains_copy:
22 archive = item.copy_source_archive
23- item = archive.getPublishedSources(
24+ items = archive.getPublishedSources(
25 exact_match=True, source_name=item.package_name,
26 version=item.package_version)
27- if item:
28- return urls(options, item[0])
29+ if items:
30+ return urls(
31+ items[0], include_source=include_source,
32+ include_binary=include_binary and item.contains_build)
33 else:
34 print("Error: Can't find source package for copy")
35 return []
36@@ -253,9 +255,9 @@ def urls(options, item):
37 ret.extend(item.customFileUrls())
38 except AttributeError: # Copies won't have this
39 ret.append(item.changesFileUrl())
40- if options.source:
41+ if include_source:
42 ret.extend(item.sourceFileUrls())
43- if options.binary:
44+ if include_binary:
45 ret.extend(item.binaryFileUrls())
46 # On staging we may get None URLs due to missing library files; filter
47 # these out.
48@@ -275,7 +277,9 @@ def fetch(options, args):
49
50
51 def fetch_item(options, item):
52- for url in urls(options, item):
53+ for url in urls(
54+ item,
55+ include_source=options.source, include_binary=options.binary):
56 path = urlsplit(url)[2]
57 filename = unquote(path.split("/")[-1])
58 exists = os.path.exists(filename)
59@@ -291,7 +295,9 @@ def show_urls(options, args):
60 """Show the URLs from which a queue item may be downloaded."""
61 items = queue_items(options, args)
62 for item in items:
63- for url in urls(options, item):
64+ for url in urls(
65+ item,
66+ include_source=options.source, include_binary=options.binary):
67 print(url)
68 return 0 if items else 1
69

Subscribers

People subscribed via source and target branches