summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-06 18:22:35 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-11-06 18:22:35 +0900
commit0ed7bd122679f82158a000a8bca5cd868fbdfb4e (patch)
tree09b943f97baf30ead0caa25e07ea1acdf11d1a5c
parent27aac095bdb6b0025c989572789a1f98d8d89b3c (diff)
downloadbuildstream-0ed7bd122679f82158a000a8bca5cd868fbdfb4e.tar.gz
Refactoring: Rename _ArtifactError -> ArtifactError
This is now part of the already private _exceptions module
-rw-r--r--buildstream/_artifactcache/artifactcache.py2
-rw-r--r--buildstream/_artifactcache/ostreecache.py40
-rw-r--r--buildstream/_artifactcache/tarcache.py16
-rw-r--r--buildstream/_exceptions.py2
-rw-r--r--buildstream/_pipeline.py6
-rw-r--r--buildstream/element.py2
6 files changed, 34 insertions, 34 deletions
diff --git a/buildstream/_artifactcache/artifactcache.py b/buildstream/_artifactcache/artifactcache.py
index 66e6520c9..ac4f6080d 100644
--- a/buildstream/_artifactcache/artifactcache.py
+++ b/buildstream/_artifactcache/artifactcache.py
@@ -108,7 +108,7 @@ class ArtifactCache():
# element (Element): The Element to extract
#
# Raises:
- # _ArtifactError: In cases there was an OSError, or if the artifact
+ # ArtifactError: In cases there was an OSError, or if the artifact
# did not exist.
#
# Returns: path to extracted artifact
diff --git a/buildstream/_artifactcache/ostreecache.py b/buildstream/_artifactcache/ostreecache.py
index d958c0bc5..431dd565a 100644
--- a/buildstream/_artifactcache/ostreecache.py
+++ b/buildstream/_artifactcache/ostreecache.py
@@ -24,7 +24,7 @@ import string
import tempfile
from .. import _ostree, utils
-from .._exceptions import _ArtifactError
+from .._exceptions import ArtifactError
from ..element import _KeyStrength
from .._ostree import OSTreeError
@@ -85,8 +85,8 @@ class OSTreeCache(ArtifactCache):
check_push_connection(self.artifact_push,
self.artifact_push_port)
except PushException as e:
- raise _ArtifactError("BuildStream will be unable to push artifacts "
- "to the shared cache: {}".format(e))
+ raise ArtifactError("BuildStream will be unable to push artifacts "
+ "to the shared cache: {}".format(e))
# contains():
#
@@ -160,7 +160,7 @@ class OSTreeCache(ArtifactCache):
# element (Element): The Element to extract
#
# Raises:
- # _ArtifactError: In cases there was an OSError, or if the artifact
+ # ArtifactError: In cases there was an OSError, or if the artifact
# did not exist.
#
# Returns: path to extracted artifact
@@ -178,7 +178,7 @@ class OSTreeCache(ArtifactCache):
rev = _ostree.checksum(self.repo, ref)
if not rev:
- raise _ArtifactError("Artifact missing for {}".format(ref))
+ raise ArtifactError("Artifact missing for {}".format(ref))
dest = os.path.join(self.extractdir, element.get_project().name, element.normal_name, rev)
if os.path.isdir(dest):
@@ -202,8 +202,8 @@ class OSTreeCache(ArtifactCache):
# If rename fails with these errors, another process beat
# us to it so just ignore.
if e.errno not in [os.errno.ENOTEMPTY, os.errno.EEXIST]:
- raise _ArtifactError("Failed to extract artifact for ref '{}': {}"
- .format(ref, e)) from e
+ raise ArtifactError("Failed to extract artifact for ref '{}': {}"
+ .format(ref, e)) from e
return dest
@@ -225,7 +225,7 @@ class OSTreeCache(ArtifactCache):
try:
_ostree.commit(self.repo, content, ref, weak_ref)
except OSTreeError as e:
- raise _ArtifactError("Failed to commit artifact: {}".format(e)) from e
+ raise ArtifactError("Failed to commit artifact: {}".format(e)) from e
# pull():
#
@@ -238,14 +238,14 @@ class OSTreeCache(ArtifactCache):
def pull(self, element, progress=None):
if self._offline and not self._pull_local:
- raise _ArtifactError("Attempt to pull artifact while offline")
+ raise ArtifactError("Attempt to pull artifact while offline")
if self.artifact_pull.startswith("/"):
remote = "file://" + self.artifact_pull
elif self.remote is not None:
remote = self.remote
else:
- raise _ArtifactError("Attempt to pull artifact without any pull URL")
+ raise ArtifactError("Attempt to pull artifact without any pull URL")
weak_ref = buildref(element, element._get_cache_key(strength=_KeyStrength.WEAK))
@@ -276,11 +276,11 @@ class OSTreeCache(ArtifactCache):
# create tag for strong cache key
_ostree.set_ref(self.repo, ref, rev)
else:
- raise _ArtifactError("Attempt to pull unavailable artifact for element {}"
- .format(element.name))
+ raise ArtifactError("Attempt to pull unavailable artifact for element {}"
+ .format(element.name))
except OSTreeError as e:
- raise _ArtifactError("Failed to pull artifact for element {}: {}"
- .format(element.name, e)) from e
+ raise ArtifactError("Failed to pull artifact for element {}: {}"
+ .format(element.name, e)) from e
# fetch_remote_refs():
#
@@ -292,7 +292,7 @@ class OSTreeCache(ArtifactCache):
elif self.remote is not None:
remote = self.remote
else:
- raise _ArtifactError("Attempt to fetch remote refs without any pull URL")
+ raise ArtifactError("Attempt to fetch remote refs without any pull URL")
def child_action(repo, remote, q):
try:
@@ -309,7 +309,7 @@ class OSTreeCache(ArtifactCache):
if ret:
self._remote_refs = res
else:
- raise _ArtifactError("Failed to fetch remote refs") from res
+ raise ArtifactError("Failed to fetch remote refs") from res
# push():
#
@@ -323,14 +323,14 @@ class OSTreeCache(ArtifactCache):
# and no updated was required
#
# Raises:
- # _ArtifactError if there was an error
+ # (ArtifactError): if there was an error
def push(self, element):
if self._offline and not self._push_local:
- raise _ArtifactError("Attempt to push artifact while offline")
+ raise ArtifactError("Attempt to push artifact while offline")
if self.artifact_push is None:
- raise _ArtifactError("Attempt to push artifact without any push URL")
+ raise ArtifactError("Attempt to push artifact without any push URL")
ref = buildref(element, element._get_cache_key_from_artifact())
weak_ref = buildref(element, element._get_cache_key(strength=_KeyStrength.WEAK))
@@ -364,7 +364,7 @@ class OSTreeCache(ArtifactCache):
self.artifact_push_port,
[ref, weak_ref], output_file)
except PushException as e:
- raise _ArtifactError("Failed to push artifact {}: {}".format(ref, e)) from e
+ raise ArtifactError("Failed to push artifact {}: {}".format(ref, e)) from e
return pushed
diff --git a/buildstream/_artifactcache/tarcache.py b/buildstream/_artifactcache/tarcache.py
index 5f28dcb41..3d4c925f0 100644
--- a/buildstream/_artifactcache/tarcache.py
+++ b/buildstream/_artifactcache/tarcache.py
@@ -26,7 +26,7 @@ import subprocess
from .. import utils
from ..element import _KeyStrength
from .._message import Message, MessageType
-from .._exceptions import _ArtifactError, ProgramNotFoundError
+from .._exceptions import ArtifactError, ProgramNotFoundError
from . import ArtifactCache
@@ -80,8 +80,8 @@ class Tar():
try:
cls._archive_with_python(location, content, cwd)
except tarfile.TarError as e:
- raise _ArtifactError("Failed to archive {}: {}"
- .format(location, e)) from e
+ raise ArtifactError("Failed to archive {}: {}"
+ .format(location, e)) from e
# extract()
#
@@ -109,8 +109,8 @@ class Tar():
try:
cls._extract_with_python(location, dest)
except tarfile.TarError as e:
- raise _ArtifactError("Failed to extract {}: {}"
- .format(location, e)) from e
+ raise ArtifactError("Failed to extract {}: {}"
+ .format(location, e)) from e
# _get_host_tar()
#
@@ -318,7 +318,7 @@ class TarCache(ArtifactCache):
path = tarpath(element, key)
if not os.path.isfile(os.path.join(self.tardir, path)):
- raise _ArtifactError("Artifact missing for {}".format(ref))
+ raise ArtifactError("Artifact missing for {}".format(ref))
# If the destination already exists, the artifact has been extracted
dest = os.path.join(self.extractdir, ref)
@@ -341,7 +341,7 @@ class TarCache(ArtifactCache):
# If rename fails with these errors, another process beat
# us to it so just ignore.
if e.errno not in [os.errno.ENOTEMPTY, os.errno.EEXIST]:
- raise _ArtifactError("Failed to extract artifact for ref '{}': {}"
- .format(ref, e)) from e
+ raise ArtifactError("Failed to extract artifact for ref '{}': {}"
+ .format(ref, e)) from e
return dest
diff --git a/buildstream/_exceptions.py b/buildstream/_exceptions.py
index c1deee786..587e8dd80 100644
--- a/buildstream/_exceptions.py
+++ b/buildstream/_exceptions.py
@@ -166,5 +166,5 @@ class SandboxError(_BstError):
#
# Raised when errors are encountered in the artifact caches
#
-class _ArtifactError(_BstError):
+class ArtifactError(_BstError):
pass
diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py
index 1df57a9c1..c7cd61ecf 100644
--- a/buildstream/_pipeline.py
+++ b/buildstream/_pipeline.py
@@ -29,7 +29,7 @@ from operator import itemgetter
from tempfile import TemporaryDirectory
from pluginbase import PluginBase
-from ._exceptions import _BstError, _ArtifactError, ImplError, LoadError
+from ._exceptions import _BstError, ArtifactError, ImplError, LoadError
from ._message import Message, MessageType
from ._elementfactory import ElementFactory
from ._loader import Loader
@@ -185,7 +185,7 @@ class Pipeline():
if remote_ticker:
remote_ticker(self.artifacts.artifact_pull)
self.artifacts.fetch_remote_refs()
- except _ArtifactError:
+ except ArtifactError:
self.message(MessageType.WARN, "Failed to fetch remote refs")
self.artifacts.set_offline()
@@ -307,7 +307,7 @@ class Pipeline():
self.message(MessageType.START, "Checking connectivity to remote artifact cache")
try:
self.artifacts.preflight()
- except _ArtifactError as e:
+ except ArtifactError as e:
self.message(MessageType.WARN, str(e),
elapsed=datetime.datetime.now() - starttime)
return False
diff --git a/buildstream/element.py b/buildstream/element.py
index 054c75667..ac5d69ac6 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -37,7 +37,7 @@ import shutil
from . import _yaml
from ._variables import Variables
-from ._exceptions import _BstError, _ArtifactError, LoadError, LoadErrorReason, ImplError
+from ._exceptions import _BstError, LoadError, LoadErrorReason, ImplError
from . import Plugin, Consistency
from .project import BST_ARTIFACT_VERSION as BST_CORE_ARTIFACT_VERSION
from . import SandboxFlags