@@ -203,7 +203,7 @@ def compare(self):
203
203
except YamlException , ye :
204
204
_logger .severe ('WLSDPLY-05708' , file_name , ye .getLocalizedMessage (),
205
205
error = ye , class_name = _class_name , method_name = _method_name )
206
- return 2
206
+ System . exit ( ExitCode . ERROR )
207
207
else :
208
208
# write the change model to standard output in YAML format
209
209
print (format_message ('WLSDPLY-05707' ))
@@ -232,6 +232,12 @@ def debug(format_string, *arguments):
232
232
else :
233
233
_logger .finest (format_string , arguments )
234
234
235
+ def _check_model_extension (file ):
236
+ model_file = JFile (file )
237
+ if not (FileUtils .isYamlFile (model_file ) or FileUtils .isJsonFile (model_file )):
238
+ return False
239
+ else :
240
+ return True
235
241
236
242
def main ():
237
243
"""
@@ -254,25 +260,16 @@ def main():
254
260
255
261
for f in [model1 , model2 ]:
256
262
if not os .path .exists (f ):
257
- raise CLAException ("Model %s does not exists" % f )
263
+ raise CLAException (ExitCode . ERROR , 'WLSDPLY-85717' , [ f ] )
258
264
if os .path .isdir (f ):
259
- raise CLAException ("Model %s is a directory" % f )
260
-
261
- model1_file = JFile (model1 )
262
- model2_file = JFile (model2 )
263
-
264
- if not (FileUtils .isYamlFile (model1_file ) or FileUtils .isJsonFile (model1_file )):
265
- raise CLAException ("Model extension must be either yaml or json" )
266
-
267
- if not (FileUtils .isYamlFile (model1_file ) and FileUtils .isYamlFile (model2_file )
268
- or FileUtils .isJsonFile (model1_file ) and FileUtils .isJsonFile (model2_file )):
269
- ext = os .path .splitext (model1 )[1 ]
270
- raise CLAException ("Model %s is not a %s file " % (model2 , ext ))
265
+ raise CLAException (ExitCode .ERROR , 'WLSDPLY-85718' , [f ])
266
+ if not _check_model_extension (f ):
267
+ raise CLAException (ExitCode .ERROR , 'WLSDPLY-85719' , [f ])
271
268
272
269
obj = ModelFileDiffer (model1 , model2 , model_context , _outputdir )
273
270
rc = obj .compare ()
274
271
if rc == VALIDATION_FAIL :
275
- System .exit (2 )
272
+ System .exit (ExitCode . ERROR )
276
273
277
274
if _outputdir :
278
275
fos = None
@@ -317,7 +314,7 @@ def main():
317
314
System .exit (0 )
318
315
319
316
except CLAException , ex :
320
- exit_code = 2
317
+ exit_code = ex . getExitCode ()
321
318
if exit_code != ExitCode .HELP :
322
319
_logger .severe ('WLSDPLY-20008' , _program_name , ex .getLocalizedMessage (), error = ex ,
323
320
class_name = _class_name , method_name = _method_name )
@@ -326,17 +323,17 @@ def main():
326
323
except CompareException , ce :
327
324
cla_helper .clean_up_temp_files ()
328
325
_logger .severe ('WLSDPLY-05704' , ce .getLocalizedMessage (), class_name = _class_name , method_name = _method_name )
329
- System .exit (2 )
326
+ System .exit (ExitCode . ERROR )
330
327
except PyWLSTException , pe :
331
328
cla_helper .clean_up_temp_files ()
332
329
_logger .severe ('WLSDPLY-05704' , pe .getLocalizedMessage (), class_name = _class_name , method_name = _method_name )
333
- System .exit (2 )
330
+ System .exit (ExitCode . ERROR )
334
331
except :
335
332
exc_type , exc_obj , exc_tb = sys .exc_info ()
336
333
ee_string = traceback .format_exception (exc_type , exc_obj , exc_tb )
337
334
cla_helper .clean_up_temp_files ()
338
335
_logger .severe ('WLSDPLY-05704' , ee_string )
339
- System .exit (2 )
336
+ System .exit (ExitCode . ERROR )
340
337
341
338
342
339
def format_message (key , * args ):
0 commit comments