~ubuntu-archive/ubuntu-archive-scripts/trunk

« back to all changes in this revision

Viewing changes to generate-team-p-m

  • Committer: Iain Lane
  • Date: 2020-04-07 09:39:31 UTC
  • mto: This revision was merged to the branch mainline in revision 271.
  • Revision ID: iain.lane@canonical.com-20200407093931-8xiiv77flibpwkwx
generate-team-p-m: Handle a missing policy_info

Migration items for binaries only "foo/arch" don't have policies run for them
but we currently assume they do, and crash when we can't find the "policy_info"
dict entry.

Handle it being missing. Return "-1" for the age and treat that as being
unknown: it's not output for these entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
206
206
        if self._age is not None:
207
207
            return self._age
208
208
        else:
209
 
            return self.data["policy_info"]["age"]["current-age"]
 
209
            try:
 
210
                return self.data["policy_info"]["age"]["current-age"]
 
211
            except KeyError:
 
212
                return -1
210
213
 
211
214
    @age.setter
212
215
    def age(self, val):
249
252
        # Missing component means main
250
253
        if item.get('component', 'main') not in components:
251
254
            continue
252
 
        prob = Problem(kind='package-in-proposed', data=item, package_in_proposed=source_package_name)
 
255
        prob = Problem(kind='package-in-proposed', data=defaultdict(dict, item), package_in_proposed=source_package_name)
253
256
        in_proposed_packages[source_package_name] = prob
254
257
        prob.regressions = []
255
258
        prob.waiting = []