[Notes] [Git][BuildStream/buildstream][bst-1.2] 3 commits: git.py: Added timed activity around fetching, displaying the URL being fetched.



Title: GitLab

Tristan Van Berkom pushed to branch bst-1.2 at BuildStream / buildstream

Commits:

2 changed files:

Changes:

  • buildstream/plugins/sources/git.py
    ... ... @@ -164,10 +164,18 @@ class GitMirror(SourceFetcher):
    164 164
                              cwd=self.mirror)
    
    165 165
     
    
    166 166
         def fetch(self, alias_override=None):
    
    167
    -        self.ensure(alias_override)
    
    168
    -        if not self.has_ref():
    
    169
    -            self._fetch(alias_override)
    
    170
    -        self.assert_ref()
    
    167
    +        # Resolve the URL for the message
    
    168
    +        resolved_url = self.source.translate_url(self.url,
    
    169
    +                                                 alias_override=alias_override,
    
    170
    +                                                 primary=self.primary)
    
    171
    +
    
    172
    +        with self.source.timed_activity("Fetching from {}"
    
    173
    +                                        .format(resolved_url),
    
    174
    +                                        silent_nested=True):
    
    175
    +            self.ensure(alias_override)
    
    176
    +            if not self.has_ref():
    
    177
    +                self._fetch(alias_override)
    
    178
    +            self.assert_ref()
    
    171 179
     
    
    172 180
         def has_ref(self):
    
    173 181
             if not self.ref:
    

  • buildstream/source.py
    ... ... @@ -585,28 +585,48 @@ class Source(Plugin):
    585 585
         #
    
    586 586
         def _fetch(self):
    
    587 587
             project = self._get_project()
    
    588
    -        source_fetchers = self.get_source_fetchers()
    
    588
    +        context = self._get_context()
    
    589
    +
    
    590
    +        # Silence the STATUS messages which might happen as a result
    
    591
    +        # of checking the source fetchers.
    
    592
    +        with context.silence():
    
    593
    +            source_fetchers = self.get_source_fetchers()
    
    589 594
     
    
    590 595
             # Use the source fetchers if they are provided
    
    591 596
             #
    
    592 597
             if source_fetchers:
    
    593
    -            for fetcher in source_fetchers:
    
    594
    -                alias = fetcher._get_alias()
    
    595
    -                for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
    
    596
    -                    try:
    
    597
    -                        fetcher.fetch(uri)
    
    598
    -                    # FIXME: Need to consider temporary vs. permanent failures,
    
    599
    -                    #        and how this works with retries.
    
    600
    -                    except BstError as e:
    
    601
    -                        last_error = e
    
    602
    -                        continue
    
    603
    -
    
    604
    -                    # No error, we're done with this fetcher
    
    605
    -                    break
    
    606 598
     
    
    607
    -                else:
    
    608
    -                    # No break occurred, raise the last detected error
    
    609
    -                    raise last_error
    
    599
    +            # Use a contorted loop here, this is to allow us to
    
    600
    +            # silence the messages which can result from consuming
    
    601
    +            # the items of source_fetchers, if it happens to be a generator.
    
    602
    +            #
    
    603
    +            source_fetchers = iter(source_fetchers)
    
    604
    +            try:
    
    605
    +
    
    606
    +                while True:
    
    607
    +
    
    608
    +                    with context.silence():
    
    609
    +                        fetcher = next(source_fetchers)
    
    610
    +
    
    611
    +                    alias = fetcher._get_alias()
    
    612
    +                    for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
    
    613
    +                        try:
    
    614
    +                            fetcher.fetch(uri)
    
    615
    +                        # FIXME: Need to consider temporary vs. permanent failures,
    
    616
    +                        #        and how this works with retries.
    
    617
    +                        except BstError as e:
    
    618
    +                            last_error = e
    
    619
    +                            continue
    
    620
    +
    
    621
    +                        # No error, we're done with this fetcher
    
    622
    +                        break
    
    623
    +
    
    624
    +                    else:
    
    625
    +                        # No break occurred, raise the last detected error
    
    626
    +                        raise last_error
    
    627
    +
    
    628
    +            except StopIteration:
    
    629
    +                pass
    
    610 630
     
    
    611 631
             # Default codepath is to reinstantiate the Source
    
    612 632
             #
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]