diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-09 16:04:21 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-07-10 16:24:28 +0900 |
commit | 2a2f37f75a524c9e1accf3a152569d70c04be174 (patch) | |
tree | 0919cd3de561732387877cccbdbd8498c46b1611 | |
parent | 056c45c8394aca8163642b37d6d2918020276054 (diff) | |
download | buildstream-2a2f37f75a524c9e1accf3a152569d70c04be174.tar.gz |
element.py: Renamed Element.fetch() to Element.pull()
For better readability; also now avoid the FAILURE messages when
an artifact fails to be pulled, replaced with self.info() message
only if the artifact was downloaded.
-rw-r--r-- | buildstream/element.py | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/buildstream/element.py b/buildstream/element.py index 2e45fb588..c16bb996a 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -36,6 +36,7 @@ from ._variables import Variables from .exceptions import _BstError from . import LoadError, LoadErrorReason, ElementError, ImplError from ._sandboxbwrap import SandboxBwrap +from ._artifactcache import ArtifactError from . import Sandbox, SandboxFlags from . import Plugin, Consistency from . import utils @@ -896,19 +897,40 @@ class Element(Plugin): def _built(self): return self.__built - # _fetch(): + # _pull(): # - # Fetch artifact from remote artifact repository to local artifact cache. + # Pull artifact from remote artifact repository into local artifact cache. # - # Returns: True if the artifact has been fetched, False otherwise + # Returns: True if the artifact has been downloaded, False otherwise # - def _fetch(self): + def _pull(self): + + def progress(percent, message): + self.status(message) + + # Avoid sending failure messages by not using a timed activity + # here, in any case the overall activity is timed by the PullQueue + # in the scheduler. + # + # Instead just issue an info message about whether an artifact + # was available or not. try: - with self.timed_activity("Fetching Artifact"): - self.__artifacts.fetch(self) - return True - except: - return False + self.__artifacts.pull(self, progress=progress) + + # Notify successfull download + display_key = self._get_display_key() + self.info("Downloaded artifact {}".format(display_key)) + downloaded = True + except ArtifactError: + # Just return false, so that the frontend knows that + # the artifact was not downloaded + # + # FIXME: Ideally we would want to raise an exception here if there + # was an error, but just return False if there was no error + # an no artifact was available to download + downloaded = False + + return downloaded # _push(): # |