diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-10-02 21:05:18 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-10-02 22:18:54 +0900 |
commit | 7da5104b1e66f742337ac1bf0e740c5ef290e381 (patch) | |
tree | bca7a0089f6d049088ad8ed0f9ad3567c18544ec | |
parent | a009dcbe9fa0d3b8047dd5f6c71c4adc6ef7aa6c (diff) | |
download | buildstream-7da5104b1e66f742337ac1bf0e740c5ef290e381.tar.gz |
source.py: Silence messages while consuming source fetcherstristan/fix-status-messages-1.2
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.py | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/buildstream/source.py b/buildstream/source.py index af9474904..b8759c0d8 100644 --- a/buildstream/source.py +++ b/buildstream/source.py @@ -585,28 +585,48 @@ class Source(Plugin): # def _fetch(self): 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 # |