[PATCH][kteam-tools] ktl/tracking_bug.py: fix snap tasks lookup
Juerg Haefliger
juerg.haefliger at canonical.com
Tue Oct 17 06:12:54 UTC 2017
On 10/16/2017 04:51 PM, Kleber Sacilotto de Souza wrote:
> The layout of the snap-related information has been changed on
> kernel-series-info.yaml. So change ktl/tracking_bug.py for the new
> layout.
>
> Signed-off-by: Kleber Sacilotto de Souza <kleber.souza at canonical.com>
> ---
> ktl/tracking_bug.py | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/ktl/tracking_bug.py b/ktl/tracking_bug.py
> index 426d39b0..8ce69170 100644
> --- a/ktl/tracking_bug.py
> +++ b/ktl/tracking_bug.py
> @@ -16,6 +16,7 @@ class TrackingBug:
> self.wf = Workflow()
> self.ub = Ubuntu()
> self.__dependency_list = None
> + self.__dependency_snaps = None
> self._targeted_series_name = None
> self._series_specified = None
> self._series_target = None
> @@ -40,6 +41,27 @@ class TrackingBug:
> retval = dependent_package in self.__dependency_list
> return retval
>
> + # get_dependent_snap
> + def get_dependent_snap(self, series, main_package):
> + '''
> + Return the name of the dependent snap for the specified series/package.
> + Return None if not found.
> + '''
> + if self.__dependency_snaps is None:
> + try:
> + record = self.ub.lookup(series)
> + try:
> + self.__dependency_snaps = record['dependent-snaps'][main_package]
> + except KeyboardInterrupt:
KeyboardInterrupt?
> + self.__dependency_snaps = {}
> + except KeyError:
> + self.__dependency_snaps = {}
You can simplify this by folding the two try-excepts into a single one.
Or use get() so you don't need try-except blocks. Untested:
self.__dependency_snaps = record.get('dependent-snaps', {}).get('snap', {})
> +
> + try:
> + return self.__dependency_snaps['snap']
> + except KeyError:
> + return None
return self.__dependency_snaps.get('snap', None)
Python exceptions are somewhat expensive.
...Juerg
> +
> # valid_series
> #
> def valid_series(s, lp_series, series_specified, targeted_series_name, package):
> @@ -64,7 +86,7 @@ class TrackingBug:
> if lp_series.name == 'prepare-package-signed' and not s.has_dependent_package(targeted_series_name, package, 'signed'):
> cdebug(' no prepare-package-signed', 'yellow')
> break
> - if not s.has_dependent_package(targeted_series_name, package, 'snap'):
> + if s.get_dependent_snap(targeted_series_name, package) is None:
> if lp_series.name == 'snap-release-to-edge':
> cdebug(' no snap-release-to-edge', 'yellow')
> break
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 845 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/kernel-team/attachments/20171017/e92e4d36/attachment.sig>
More information about the kernel-team
mailing list