From 0913bb21dd26ec871a683d77a9e623f2be3716f5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 27 Sep 2011 14:08:11 +0200 Subject: [PATCH] use raise instead of sys.exit in emulator Signed-off-by: Nico Schottelius --- lib/cdist/emulator.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/cdist/emulator.py b/lib/cdist/emulator.py index 33594e45..68a67176 100644 --- a/lib/cdist/emulator.py +++ b/lib/cdist/emulator.py @@ -22,7 +22,6 @@ import argparse import logging import os -import sys import cdist import cdist.path @@ -101,18 +100,22 @@ def run(argv): # Already exists, verify all parameter are the same if object_exists: if not os.path.isfile(file): - print("New parameter + \"" + param + "\" specified, aborting") - print("Source = " + " ".join(old_object_source) + " new =" + object_source) - sys.exit(1) + raise cdist.Error("New parameter \"" + + param + "\" specified, aborting\n" + + "Source = " + + " ".join(old_object_source) + + " new =" + object_source) else: param_fd = open(file, "r") value_old = param_fd.readlines() param_fd.close() if(value_old != value): - print("Parameter " + param + " differs: " + " ".join(value_old) + " vs. " + value) - print("Sources: " + " ".join(old_object_source) + " and " + object_source) - sys.exit(1) + raise cdist.Error("Parameter + \"" + param + + "\" differs: " + " ".join(value_old) + " vs. " + + value + + "\nSource = " + " ".join(old_object_source) + + " new =" + object_source) else: param_fd = open(file, "w") param_fd.writelines(value) @@ -131,7 +134,6 @@ def run(argv): source_fd.writelines(object_source) source_fd.close() - # sys.exit(1) print("Finished " + type + "/" + object_id + repr(params))