summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-10-02 21:11:35 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-10-03 07:33:48 +0000
commitb645881cfa5f20d443a621824b45c4178e1cda2c (patch)
tree1e6a14381bf3586bee3d7e753173887bbe5cc224
parent29c19bead406e76b6b7cf50b6e354d44b17e6182 (diff)
downloadbuildstream-tristan/fix-status-messages.tar.gz
source.py: Silence messages while consuming source fetcherstristan/fix-status-messages
The source fetchers might be a list or a generator, when it is a generator (like the git source does), then we want to ensure that we silence the status messages which might occur as a result of consuming a source fetcher from the generator. This fixes the logs to be less verbose.
-rw-r--r--buildstream/source.py54
1 files changed, 37 insertions, 17 deletions
diff --git a/buildstream/source.py b/buildstream/source.py
index 5324f42a8..6768f6cfc 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -965,28 +965,48 @@ class Source(Plugin):
# Tries to call fetch for every mirror, stopping once it succeeds
def __do_fetch(self, **kwargs):
project = self._get_project()
- source_fetchers = self.get_source_fetchers()
+ context = self._get_context()
+
+ # Silence the STATUS messages which might happen as a result
+ # of checking the source fetchers.
+ with context.silence():
+ source_fetchers = self.get_source_fetchers()
# Use the source fetchers if they are provided
#
if source_fetchers:
- for fetcher in source_fetchers:
- alias = fetcher._get_alias()
- for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
- try:
- fetcher.fetch(uri)
- # 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
+ # 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)
+ try:
+
+ while True:
+
+ with context.silence():
+ fetcher = next(source_fetchers)
+
+ alias = fetcher._get_alias()
+ for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
+ try:
+ fetcher.fetch(uri)
+ # 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
+
+ except StopIteration:
+ pass
# Default codepath is to reinstantiate the Source
#