in src/buildstream/source.py [0:0]
def __do_fetch(self, **kwargs):
project = self._get_project()
context = self._get_context()
# Silence the STATUS messages which might happen as a result
# of checking the source fetchers.
with context.messenger.silence():
source_fetchers = self.get_source_fetchers()
# Use the source fetchers if they are provided
#
if source_fetchers:
# Use a contorted loop here, this is to allow us to
# silence the messages which can result from consuming
# the items of source_fetchers, if it happens to be a generator.
#
source_fetchers = iter(source_fetchers)
while True:
with context.messenger.silence():
try:
fetcher = next(source_fetchers)
except StopIteration:
# as per PEP479, we are not allowed to let StopIteration
# thrown from a context manager.
# Catching it here and breaking instead.
break
alias = fetcher._get_alias()
last_error = None
for mirror in project.get_alias_uris(alias, first_pass=self.__first_pass, tracking=False):
try:
fetcher.fetch(mirror)
# FIXME: Need to consider temporary vs. permanent failures,
# and how this works with retries.
except BstError as e:
last_error = e
continue
# No error, we're done with this fetcher
break
else:
# No break occurred, raise the last detected error
raise last_error
# Default codepath is to reinstantiate the Source
#
else:
alias = self._get_alias()
if self.__first_pass:
mirrors = project.first_pass_config.mirrors
else:
mirrors = project.config.mirrors
if not mirrors or not alias:
self.fetch(**kwargs)
return
last_error = None
for mirror in project.get_alias_uris(alias, first_pass=self.__first_pass, tracking=False):
new_source = self.__clone_for_uri(mirror)
try:
new_source.fetch(**kwargs)
# FIXME: Need to consider temporary vs. permanent failures,
# and how this works with retries.
except BstError as e:
last_error = e
continue
# No error, we're done here
return
# Re raise the last detected error
raise last_error