in mozdownload/scraper.py [0:0]
def get_build_info(self):
"""Define additional build information."""
# Retrieve branch once knowing self.application from Scraper.__init__
if self.branch is None:
self.branch = APPLICATIONS_TO_BRANCH.get(self.application, DEFAULT_BRANCH)
# Retrieve build by revision
if self.revision:
th = treeherder.Treeherder(self.application, self.branch, self.platform)
builds = th.query_builds_by_revision(
self.revision,
job_type_name='L10n Nightly' if self.locale_build else 'Nightly')
if not builds:
raise errors.NotFoundError('No builds have been found for revision', self.revision)
# Extract the build folders which are prefixed with the buildid
self.builds = [build.rsplit('/', 2)[1] for build in builds]
self.show_matching_builds(self.builds)
# There is only a single build per revision and platform
self.build_index = 0
self.logger.info('Selected build: %s' % self.builds[self.build_index])
# Retrieve the date from the build folder which is always 19 chars long
self.date = datetime.strptime(self.builds[self.build_index][:19],
'%Y-%m-%d-%H-%M-%S')
return
# Internally we access builds via index
if self.build_number is not None:
self.build_index = int(self.build_number) - 1
else:
self.build_index = None
if self.build_id:
# A build id has been specified. Split up its components so the
# date and time can be extracted:
# '20111212042025' -> '2011-12-12 04:20:25'
self.date = datetime.strptime(self.build_id, '%Y%m%d%H%M%S')
elif self.date:
# A date (without time) has been specified. Use its value and the
# build index to find the requested build for that day.
try:
self.date = datetime.strptime(self.date, '%Y-%m-%d')
except Exception:
raise ValueError('%s is not a valid date' % self.date)
else:
# If no querying option has been specified the latest available
# build of the given branch has to be identified. We also have to
# retrieve the date of the build via its build id.
self.date = self.get_latest_build_date()
self.builds, self.build_index = self.get_build_info_for_date(
self.date, self.build_index)