[Notes] [Git][BuildStream/buildstream][master] 4 commits: source.py: Stylistic changes in Source.__do_fetch()



Title: GitLab

Tristan Van Berkom pushed to branch master at BuildStream / buildstream

Commits:

2 changed files:

Changes:

  • buildstream/plugins/sources/git.py
    ... ... @@ -387,8 +387,10 @@ class GitSource(Source):
    387 387
                                       detail=detail, reason="track-attempt-no-track")
    
    388 388
                 return None
    
    389 389
     
    
    390
    +        # Resolve the URL for the message
    
    391
    +        resolved_url = self.translate_url(self.mirror.url)
    
    390 392
             with self.timed_activity("Tracking {} from {}"
    
    391
    -                                 .format(self.tracking, self.mirror.url),
    
    393
    +                                 .format(self.tracking, resolved_url),
    
    392 394
                                      silent_nested=True):
    
    393 395
                 self.mirror.ensure()
    
    394 396
                 self.mirror._fetch()
    

  • buildstream/source.py
    ... ... @@ -445,19 +445,6 @@ class Source(Plugin):
    445 445
             """
    
    446 446
             self.stage(directory)
    
    447 447
     
    
    448
    -    def mark_download_url(self, url):
    
    449
    -        """Identifies the URL that this Source uses to download
    
    450
    -
    
    451
    -        This must be called during :func:`~buildstream.plugin.Plugin.configure` if
    
    452
    -        :func:`~buildstream.source.Source.translate_url` is not called.
    
    453
    -
    
    454
    -        Args:
    
    455
    -           url (str): The url used to download
    
    456
    -
    
    457
    -        *Since: 1.2*
    
    458
    -        """
    
    459
    -        self.__expected_alias = _extract_alias(url)
    
    460
    -
    
    461 448
         def get_source_fetchers(self):
    
    462 449
             """Get the objects that are used for fetching
    
    463 450
     
    
    ... ... @@ -526,6 +513,19 @@ class Source(Plugin):
    526 513
                 project = self._get_project()
    
    527 514
                 return project.translate_url(url, first_pass=self.__first_pass)
    
    528 515
     
    
    516
    +    def mark_download_url(self, url):
    
    517
    +        """Identifies the URL that this Source uses to download
    
    518
    +
    
    519
    +        This must be called during :func:`~buildstream.plugin.Plugin.configure` if
    
    520
    +        :func:`~buildstream.source.Source.translate_url` is not called.
    
    521
    +
    
    522
    +        Args:
    
    523
    +           url (str): The url used to download
    
    524
    +
    
    525
    +        *Since: 1.2*
    
    526
    +        """
    
    527
    +        self.__expected_alias = _extract_alias(url)
    
    528
    +
    
    529 529
         def get_project_directory(self):
    
    530 530
             """Fetch the project base directory
    
    531 531
     
    
    ... ... @@ -865,10 +865,12 @@ class Source(Plugin):
    865 865
         def __do_fetch(self, **kwargs):
    
    866 866
             project = self._get_project()
    
    867 867
             source_fetchers = self.get_source_fetchers()
    
    868
    +
    
    869
    +        # Use the source fetchers if they are provided
    
    870
    +        #
    
    868 871
             if source_fetchers:
    
    869 872
                 for fetcher in source_fetchers:
    
    870 873
                     alias = fetcher._get_alias()
    
    871
    -                success = False
    
    872 874
                     for uri in project.get_alias_uris(alias, first_pass=self.__first_pass):
    
    873 875
                         try:
    
    874 876
                             fetcher.fetch(uri)
    
    ... ... @@ -877,10 +879,16 @@ class Source(Plugin):
    877 879
                         except BstError as e:
    
    878 880
                             last_error = e
    
    879 881
                             continue
    
    880
    -                    success = True
    
    882
    +
    
    883
    +                    # No error, we're done with this fetcher
    
    881 884
                         break
    
    882
    -                if not success:
    
    885
    +
    
    886
    +                else:
    
    887
    +                    # No break occurred, raise the last detected error
    
    883 888
                         raise last_error
    
    889
    +
    
    890
    +        # Default codepath is to reinstantiate the Source
    
    891
    +        #
    
    884 892
             else:
    
    885 893
                 alias = self._get_alias()
    
    886 894
                 if self.__first_pass:
    
    ... ... @@ -904,7 +912,11 @@ class Source(Plugin):
    904 912
                     except BstError as e:
    
    905 913
                         last_error = e
    
    906 914
                         continue
    
    915
    +
    
    916
    +                # No error, we're done here
    
    907 917
                     return
    
    918
    +
    
    919
    +            # Re raise the last detected error
    
    908 920
                 raise last_error
    
    909 921
     
    
    910 922
         # Tries to call track for every mirror, stopping once it succeeds
    



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