forked from ungleich-public/cdist
use raise instead of sys.exit in emulator
Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
parent
9d582ae24f
commit
0913bb21dd
1 changed files with 10 additions and 8 deletions
|
@ -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))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue