diff --git a/core/src/main/python/wlsdeploy/tool/modelhelp/model_help_interactive_printer.py b/core/src/main/python/wlsdeploy/tool/modelhelp/model_help_interactive_printer.py index 9a70214884..6fbf1a1f1e 100644 --- a/core/src/main/python/wlsdeploy/tool/modelhelp/model_help_interactive_printer.py +++ b/core/src/main/python/wlsdeploy/tool/modelhelp/model_help_interactive_printer.py @@ -66,7 +66,7 @@ def interactive_help_main_loop(self): self._output_buffer.add_output() self._output_buffer.print_output() - command_str = _interactive_help_prompt(history[-1], reader) + command_str = self._interactive_help_prompt(history[-1], reader) self._logger.exiting(class_name=_class_name, method_name=_method_name) @@ -286,25 +286,32 @@ def _add_message(self, key, *args, **kwargs): self._output_buffer.add_output('%s%s%s' % (prefix, message, suffix)) -def _interactive_help_prompt(model_path, reader): - """ - Gets the next command from stdin or using JLine. - :param model_path: a current model path - :param reader: JLine reader, or None if JLine not supported - :return: returns when user types 'exit' - """ - prompt = '[%s] --> ' % model_path + def _interactive_help_prompt(self, model_path, reader): + """ + Gets the next command from stdin or using JLine. + :param model_path: a current model path + :param reader: JLine reader, or None if JLine not supported + :return: returns when user types 'exit' + """ + prompt = '[%s] --> ' % model_path - if reader: - command_str = reader.readLine(prompt) - else: - # prompt using sys.stdout.write to avoid newline - sys.stdout.write(prompt) - sys.stdout.flush() - command_str = raw_input('') # get command from stdin + if reader: + # reader is None if JLine is not loaded + from org.jline.reader import EndOfFileException + + try: + command_str = reader.readLine(prompt) + except EndOfFileException,ex: + self._logger.fine('WLSDPLY-10141', error=ex) + command_str = 'exit' + else: + # prompt using sys.stdout.write to avoid newline + sys.stdout.write(prompt) + sys.stdout.flush() + command_str = raw_input('') # get command from stdin - command_str = ' '.join(command_str.split()) # remove extra white-space - return command_str + command_str = ' '.join(command_str.split()) # remove extra white-space + return command_str def _canonical_path_from_model_path(model_path): diff --git a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties index fd13fa4c66..e0a4039d7c 100644 --- a/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties +++ b/core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties @@ -1704,6 +1704,7 @@ WLSDPLY-10136=Examples WLSDPLY-10137=Model section {0} has no element {1} beneath it. Valid folders are: {2}. Valid attributes are {3}. WLSDPLY-10138=Failed to describe location {0}: {1} WLSDPLY-10140=Show details for the specified attribute location +WLSDPLY-10141=Gracefully exiting the Model Help tool due to a JLine EndOfFileException, which is usually triggered by the user pressing Control-D to exit the shell. ############################################################################### # create messages (12000 - 14999) #