@@ -203,7 +203,7 @@ def compare(self):
203203 except YamlException , ye :
204204 _logger .severe ('WLSDPLY-05708' , file_name , ye .getLocalizedMessage (),
205205 error = ye , class_name = _class_name , method_name = _method_name )
206- return 2
206+ System . exit ( ExitCode . ERROR )
207207 else :
208208 # write the change model to standard output in YAML format
209209 print (format_message ('WLSDPLY-05707' ))
@@ -232,6 +232,12 @@ def debug(format_string, *arguments):
232232 else :
233233 _logger .finest (format_string , arguments )
234234
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
235241
236242def main ():
237243 """
@@ -254,25 +260,16 @@ def main():
254260
255261 for f in [model1 , model2 ]:
256262 if not os .path .exists (f ):
257- raise CLAException ("Model %s does not exists" % f )
263+ raise CLAException (ExitCode . ERROR , 'WLSDPLY-85717' , [ f ] )
258264 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 ])
271268
272269 obj = ModelFileDiffer (model1 , model2 , model_context , _outputdir )
273270 rc = obj .compare ()
274271 if rc == VALIDATION_FAIL :
275- System .exit (2 )
272+ System .exit (ExitCode . ERROR )
276273
277274 if _outputdir :
278275 fos = None
@@ -317,7 +314,7 @@ def main():
317314 System .exit (0 )
318315
319316 except CLAException , ex :
320- exit_code = 2
317+ exit_code = ex . getExitCode ()
321318 if exit_code != ExitCode .HELP :
322319 _logger .severe ('WLSDPLY-20008' , _program_name , ex .getLocalizedMessage (), error = ex ,
323320 class_name = _class_name , method_name = _method_name )
@@ -326,17 +323,17 @@ def main():
326323 except CompareException , ce :
327324 cla_helper .clean_up_temp_files ()
328325 _logger .severe ('WLSDPLY-05704' , ce .getLocalizedMessage (), class_name = _class_name , method_name = _method_name )
329- System .exit (2 )
326+ System .exit (ExitCode . ERROR )
330327 except PyWLSTException , pe :
331328 cla_helper .clean_up_temp_files ()
332329 _logger .severe ('WLSDPLY-05704' , pe .getLocalizedMessage (), class_name = _class_name , method_name = _method_name )
333- System .exit (2 )
330+ System .exit (ExitCode . ERROR )
334331 except :
335332 exc_type , exc_obj , exc_tb = sys .exc_info ()
336333 ee_string = traceback .format_exception (exc_type , exc_obj , exc_tb )
337334 cla_helper .clean_up_temp_files ()
338335 _logger .severe ('WLSDPLY-05704' , ee_string )
339- System .exit (2 )
336+ System .exit (ExitCode . ERROR )
340337
341338
342339def format_message (key , * args ):
0 commit comments