use raise instead of sys.exit in emulator

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-09-27 14:08:11 +02:00
parent 9d582ae24f
commit 0913bb21dd

View file

@ -22,7 +22,6 @@
import argparse import argparse
import logging import logging
import os import os
import sys
import cdist import cdist
import cdist.path import cdist.path
@ -101,18 +100,22 @@ def run(argv):
# Already exists, verify all parameter are the same # Already exists, verify all parameter are the same
if object_exists: if object_exists:
if not os.path.isfile(file): if not os.path.isfile(file):
print("New parameter + \"" + param + "\" specified, aborting") raise cdist.Error("New parameter \"" +
print("Source = " + " ".join(old_object_source) + " new =" + object_source) param + "\" specified, aborting\n" +
sys.exit(1) "Source = " +
" ".join(old_object_source)
+ " new =" + object_source)
else: else:
param_fd = open(file, "r") param_fd = open(file, "r")
value_old = param_fd.readlines() value_old = param_fd.readlines()
param_fd.close() param_fd.close()
if(value_old != value): if(value_old != value):
print("Parameter " + param + " differs: " + " ".join(value_old) + " vs. " + value) raise cdist.Error("Parameter + \"" + param +
print("Sources: " + " ".join(old_object_source) + " and " + object_source) "\" differs: " + " ".join(value_old) + " vs. " +
sys.exit(1) value +
"\nSource = " + " ".join(old_object_source)
+ " new =" + object_source)
else: else:
param_fd = open(file, "w") param_fd = open(file, "w")
param_fd.writelines(value) param_fd.writelines(value)
@ -131,7 +134,6 @@ def run(argv):
source_fd.writelines(object_source) source_fd.writelines(object_source)
source_fd.close() source_fd.close()
# sys.exit(1)
print("Finished " + type + "/" + object_id + repr(params)) print("Finished " + type + "/" + object_id + repr(params))