def _getUrl(self, updateQuery, patchKey, patch, specialForceHosts): platformData = self.getPlatformData(updateQuery["buildTarget"]) if 'fileUrl' in patch: url = patch['fileUrl'] else: ftpFilename = self._getFtpFilename(patchKey, patch["from"]) bouncerProduct = self._getBouncerProduct(patchKey, patch["from"]) # When we're using a fallback channel it's unlikely # we'll have a fileUrl specifically for it, but we # should try nonetheless. Non-fallback cases shouldn't # be hitting any exceptions here. try: url = self['fileUrls'][updateQuery['channel']] except KeyError: try: url = self['fileUrls'][getFallbackChannel( updateQuery['channel'])] except KeyError: self.log.debug("Couldn't find fileUrl for") raise url = url.replace('%LOCALE%', updateQuery['locale']) url = url.replace('%OS_FTP%', platformData['OS_FTP']) url = url.replace('%FILENAME%', ftpFilename) url = url.replace('%PRODUCT%', bouncerProduct) url = url.replace('%OS_BOUNCER%', platformData['OS_BOUNCER']) # pass on forcing for special hosts (eg download.m.o for mozilla metrics) if updateQuery['force']: url = self.processSpecialForceHosts(url, specialForceHosts) return url
def _getUrl(self, updateQuery, patchKey, patch, specialForceHosts): platformData = self.getPlatformData(updateQuery["buildTarget"]) if 'fileUrl' in patch: url = patch['fileUrl'] else: ftpFilename = self._getFtpFilename(patchKey, patch["from"]) bouncerProduct = self._getBouncerProduct(patchKey, patch["from"]) # When we're using a fallback channel it's unlikely # we'll have a fileUrl specifically for it, but we # should try nonetheless. Non-fallback cases shouldn't # be hitting any exceptions here. try: url = self['fileUrls'][updateQuery['channel']] except KeyError: try: url = self['fileUrls'][getFallbackChannel(updateQuery['channel'])] except KeyError: self.log.debug("Couldn't find fileUrl for") raise url = url.replace('%LOCALE%', updateQuery['locale']) url = url.replace('%OS_FTP%', platformData['OS_FTP']) url = url.replace('%FILENAME%', ftpFilename) url = url.replace('%PRODUCT%', bouncerProduct) url = url.replace('%OS_BOUNCER%', platformData['OS_BOUNCER']) # pass on forcing for special hosts (eg download.m.o for mozilla metrics) if updateQuery['force']: url = self.processSpecialForceHosts(url, specialForceHosts) return url
def _getUrl(self, updateQuery, patchKey, patch, specialForceHosts): platformData = self.getPlatformData(updateQuery["buildTarget"]) from_ = patch["from"] # A fileUrl in the deep-down patch section takes priority over anything # else. if 'fileUrl' in patch: url = patch['fileUrl'] else: # There's three "channels" that any given request could get # a fileUrl from, in order of preference: # 1) Its exact specified channel. # 2) Its fallback channel. # 3) In the catch-all "channel" ("*"). # When a channel is present in 'fileUrls' then we don't fall back to the # 'catch-all' block if a product is missing from the channel block channels = [ updateQuery['channel'], getFallbackChannel(updateQuery['channel']), "*", ] url = None for c in channels: config_block = self.get("fileUrls", {}).get(c, {}) if config_block: url = config_block.get(patchKey, {}).get(from_) break # If we still can't find a fileUrl, we cannot fulfill this request. if not url: self.log.debug("Couldn't find fileUrl") raise ValueError("Couldn't find fileUrl") url = url.replace('%LOCALE%', updateQuery['locale']) url = url.replace('%OS_FTP%', platformData['OS_FTP']) url = url.replace('%OS_BOUNCER%', platformData['OS_BOUNCER']) url = url.replace('%locale%', updateQuery['locale']) url = url.replace('%os_ftp%', platformData['OS_FTP']) url = url.replace('%os_bouncer%', platformData['OS_BOUNCER']) # pass on forcing for special hosts (eg download.m.o for mozilla metrics) if updateQuery['force']: url = self.processSpecialForceHosts(url, specialForceHosts, updateQuery['force']) return url
def _getUrl(self, updateQuery, patchKey, patch, specialForceHosts): platformData = self.getPlatformData(updateQuery["buildTarget"]) from_ = patch["from"] # A fileUrl in the deep-down patch section takes priority over anything # else. if 'fileUrl' in patch: url = patch['fileUrl'] else: # There's three "channels" that any given request could get # a fileUrl from, in order of preference: # 1) Its exact specified channel. # 2) Its fallback channel. # 3) In the catch-all "channel" ("*"). # When a channel is present in 'fileUrls' then we don't fall back to the # 'catch-all' block if a product is missing from the channel block channels = [ updateQuery['channel'], getFallbackChannel(updateQuery['channel']), "*", ] url = None for c in channels: config_block = self.get("fileUrls", {}).get(c, {}) if config_block: url = config_block.get(patchKey, {}).get(from_) break # If we still can't find a fileUrl, we cannot fulfill this request. if not url: self.log.debug("Couldn't find fileUrl") raise ValueError("Couldn't find fileUrl") url = url.replace('%LOCALE%', updateQuery['locale']) url = url.replace('%OS_FTP%', platformData['OS_FTP']) url = url.replace('%OS_BOUNCER%', platformData['OS_BOUNCER']) url = url.replace('%locale%', updateQuery['locale']) url = url.replace('%os_ftp%', platformData['OS_FTP']) url = url.replace('%os_bouncer%', platformData['OS_BOUNCER']) # pass on forcing for special hosts (eg download.m.o for mozilla metrics) if updateQuery['force']: url = self.processSpecialForceHosts(url, specialForceHosts) return url