diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-12-29 19:39:04 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-01-01 19:39:09 +0900 |
commit | 913fcec62e7ef46372b609e589c239f5de797af8 (patch) | |
tree | f121610a1c7a45c5bfce0eb107b24494bbd5618a /buildstream/plugins | |
parent | 86b129643385363ebeea9dbc4b0d152412909948 (diff) | |
download | buildstream-913fcec62e7ef46372b609e589c239f5de797af8.tar.gz |
plugins/sources/patch.py: Added context to some errors
Diffstat (limited to 'buildstream/plugins')
-rw-r--r-- | buildstream/plugins/sources/patch.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/buildstream/plugins/sources/patch.py b/buildstream/plugins/sources/patch.py index 8ff8b1162..40fd106ec 100644 --- a/buildstream/plugins/sources/patch.py +++ b/buildstream/plugins/sources/patch.py @@ -53,9 +53,11 @@ class PatchSource(Source): def preflight(self): # Check if the configured file really exists if not os.path.exists(self.fullpath): - raise SourceError("Specified path '{}' does not exist".format(self.path)) + raise SourceError("Specified path '{}' does not exist".format(self.path), + reason="patch-no-exist") elif not os.path.isfile(self.fullpath): - raise SourceError("Specified path '{}' must be a file".format(self.path)) + raise SourceError("Specified path '{}' must be a file".format(self.path), + reason="patch-not-a-file") # Check if patch is installed, get the binary at the same time self.host_patch = utils.get_host_tool("patch") @@ -67,23 +69,25 @@ class PatchSource(Source): return Consistency.CACHED def get_ref(self): - # We dont have a ref, we"re a local file... - return None + return None # pragma: nocover def set_ref(self, ref, node): - pass + pass # pragma: nocover def fetch(self): # Nothing to do here for a local source - pass + pass # pragma: nocover def stage(self, directory): with self.timed_activity("Applying local patch: {}".format(self.path)): if not os.path.isdir(directory): raise SourceError( - "Patch directory '{}' does not exist".format(directory)) + "Patch directory '{}' does not exist".format(directory), + reason="patch-no-directory" + ) elif not os.listdir(directory): - raise SourceError("Empty patch directory '{}'".format(directory)) + raise SourceError("Empty patch directory '{}'".format(directory), + reason="patch-no-files") strip_level_option = "-p{}".format(self.strip_level) self.call([self.host_patch, strip_level_option, "-i", self.fullpath, "-d", directory], fail="Failed to apply patch {}".format(self.path)) |