18 from robot.errors import (INFO_PRINTED, DATA_ERROR, STOPPED_BY_USER,
19 FRAMEWORK_ERROR, Information, DataError)
21 from .argumentparser
import ArgumentParser
22 from .encoding
import console_encode
23 from .error
import get_error_details
28 def __init__(self, usage, name=None, version=None, arg_limits=None,
29 env_options=None, logger=None, **auto_options):
31 self.
validatevalidate, env_options, **auto_options)
34 def main(self, arguments, **options):
35 raise NotImplementedError
38 return options, arguments
44 rc = self.
_execute_execute(arguments, options)
56 except Information
as msg:
58 except DataError
as err:
59 self.
_report_error_report_error(err.message, help=
True, exit=
True)
61 self.
_logger_logger.
info(
'Arguments: %s' %
','.join(arguments))
62 return options, arguments
72 return self.
_ap_ap.parse_args(cli_args)
77 return self.
_execute_execute(list(arguments), options)
81 rc = self.
mainmain(arguments, **options)
82 except DataError
as err:
83 return self.
_report_error_report_error(err.message, help=
True)
84 except (KeyboardInterrupt, SystemExit):
85 return self.
_report_error_report_error(
'Execution stopped by user.',
89 return self.
_report_error_report_error(
'Unexpected error: %s' % error,
90 details, rc=FRAMEWORK_ERROR)
96 self.
_exit_exit(INFO_PRINTED)
98 def _report_error(self, message, details=None, help=False, rc=DATA_ERROR,
101 message +=
'\n\nTry --help for usage information.'
103 message +=
'\n' + details
def execute_cli(self, cli_arguments, exit=True)
def _report_error(self, message, details=None, help=False, rc=DATA_ERROR, exit=False)
def _parse_arguments(self, cli_args)
def main(self, arguments, **options)
def _report_info(self, message)
def __init__(self, usage, name=None, version=None, arg_limits=None, env_options=None, logger=None, **auto_options)
def validate(self, options, arguments)
def execute(self, *arguments, **options)
def parse_arguments(self, cli_args)
Public interface for parsing command line arguments.
def _execute(self, arguments, options)
def __exit__(self, *exc_info)
def info(msg, html=False, also_console=False)
Writes the message to the log file using the INFO level.
def error(msg, html=False)
Writes the message to the log file using the ERROR level.
def console_encode(string, encoding=None, errors='replace', stream=sys.__stdout__, force=False)
Encodes the given string so that it can be used in the console.
def get_error_details(full_traceback=True, exclude_robot_traces=EXCLUDE_ROBOT_TRACES)
Returns error message and details of the last occurred exception.