From 91022c3f7e7102833a4416cb45ae171f6e8d4b1e Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 23 Sep 2011 17:19:45 +0200 Subject: [PATCH] handle ioerror if script does not exist Signed-off-by: Steven Armstrong --- bin/cdist | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/cdist b/bin/cdist index fde7a251..d9f88b48 100755 --- a/bin/cdist +++ b/bin/cdist @@ -181,9 +181,12 @@ class Cdist: if remote: remote_cat(script) else: - script_fd = open(script) - print(script_fd.read()) - script_fd.close() + try: + script_fd = open(script) + print(script_fd.read()) + script_fd.close() + except IOError as error: + raise CdistError(str(error)) raise CdistError("Command failed (shell): " + " ".join(*args)) except OSError as error: