From ebe460aad183cf066e679338608a2af5b9711421 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Fri, 7 Feb 2020 06:58:10 -0500 Subject: [PATCH] lpapicache: allow getBinaries(arch=None) to get all archs this was the previous behavior and some scripts still call with no args. LP: #1862286 --- ubuntutools/archive.py | 4 ++-- ubuntutools/lp/lpapicache.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ubuntutools/archive.py b/ubuntutools/archive.py index 35402a6..8d6d329 100644 --- a/ubuntutools/archive.py +++ b/ubuntutools/archive.py @@ -608,7 +608,7 @@ class DebianSPPH(SourcePackagePublishingHistory): """ resource_type = 'source_package_publishing_history' - def getBinaries(self, arch, name=None, ext=None): + def getBinaries(self, arch=None, name=None, ext=None): Logger.info('Using Snapshot to find binary packages') srcpkg = Snapshot.getSourcePackage(self.getPackageName(), version=self.getVersion()) @@ -1228,7 +1228,7 @@ class SnapshotSPPH(object): new_entries.append(str(block)) return ''.join(new_entries) - def getBinaries(self, arch, name=None, ext=None): + def getBinaries(self, arch=None, name=None, ext=None): return [b.getBPPH() for b in self._pkg.getBinaryFiles(arch=arch, name=name, ext=ext)] diff --git a/ubuntutools/lp/lpapicache.py b/ubuntutools/lp/lpapicache.py index d26863b..ae0f13e 100644 --- a/ubuntutools/lp/lpapicache.py +++ b/ubuntutools/lp/lpapicache.py @@ -794,17 +794,19 @@ class SourcePackagePublishingHistory(BaseWrapper): new_entries.append(str(block)) return ''.join(new_entries) - def getBinaries(self, arch, name=None, ext=None): + def getBinaries(self, arch=None, name=None, ext=None): ''' Returns the resulting BinaryPackagePublishingHistorys. - Must specify arch, or use 'all' to get all archs. + If arch is specified, it returns binaries for only that arch, + plus any binaries with arch 'all'. If arch is not specified, or + if arch is specified as 'all', all archs are returned. If name is specified, only returns BPPH matching that (regex) name. If ext is specified, only returns BPPH matching that (regex) ext. ''' - if not arch: - raise RuntimeError("Must specify arch") + if arch == 'all': + arch = None if self.status in ["Pending", "Published"]: # Published, great! Directly query the list of binaries