From ad1e51cb2e75799831ed8d89ce1c2bc2bb8ac43a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 15 Oct 2011 01:11:54 +0200 Subject: [PATCH] catch unicodedecodeerror Signed-off-by: Nico Schottelius --- lib/cdist/exec/remote.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/cdist/exec/remote.py b/lib/cdist/exec/remote.py index 9610290b..c876adf1 100644 --- a/lib/cdist/exec/remote.py +++ b/lib/cdist/exec/remote.py @@ -40,6 +40,13 @@ class RemoteScriptError(cdist.Error): def __str__(self): return "Remote script execution failed: %s %s" % (self.script, self.command) +class DecodeError(cdist.Error): + def __init__(self, command): + self.command = command + + def __str__(self): + return "Cannot decode output of " + " ".join(self.command) + class Remote(object): """Execute commands remotely. @@ -121,6 +128,8 @@ class Remote(object): raise cdist.Error("Command failed: " + " ".join(command)) except OSError as error: raise cdist.Error(" ".join(*args) + ": " + error.args[1]) + except UnicodeDecodeError: + raise DecodeError(command) def run_script(self, script, env=None, return_output=False): """Run the given script with the given environment on the remote side.