16 from __future__
import print_function
21 FRAMEWORK_ERROR, Information, DataError)
23 from .argumentparser
import ArgumentParser
24 from .encoding
import console_encode
25 from .error
import get_error_details
30 def __init__(self, usage, name=None, version=None, arg_limits=None,
31 env_options=None, logger=None, **auto_options):
33 self.
validatevalidate, env_options, **auto_options)
36 def main(self, arguments, **options):
37 raise NotImplementedError
40 return options, arguments
46 rc = self.
_execute_execute(arguments, options)
58 except Information
as msg:
60 except DataError
as err:
61 self.
_report_error_report_error(err.message, help=
True, exit=
True)
63 self.
_logger_logger.
info(
'Arguments: %s' %
','.join(arguments))
64 return options, arguments
74 return self.
_ap_ap.parse_args(cli_args)
79 return self.
_execute_execute(list(arguments), options)
83 rc = self.
mainmain(arguments, **options)
84 except DataError
as err:
85 return self.
_report_error_report_error(err.message, help=
True)
86 except (KeyboardInterrupt, SystemExit):
87 return self.
_report_error_report_error(
'Execution stopped by user.',
91 return self.
_report_error_report_error(
'Unexpected error: %s' % error,
92 details, rc=FRAMEWORK_ERROR)
98 self.
_exit_exit(INFO_PRINTED)
103 message +=
'\n\nTry --help for usage information.'
105 message +=
'\n' + details
def _parse_arguments(self, cli_args)
def execute(self, *arguments, **options)
def execute_cli(self, cli_arguments, exit=True)
def parse_arguments(self, cli_args)
Public interface for parsing command line arguments.
def validate(self, options, arguments)
def _report_info(self, message)
def _execute(self, arguments, options)
def __init__(self, usage, name=None, version=None, arg_limits=None, env_options=None, logger=None, **auto_options)
def main(self, arguments, **options)
def _report_error(self, message, details=None, help=False, rc=DATA_ERROR, exit=False)
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, errors='replace', stream=sys.__stdout__)
Encodes Unicode to bytes in console or system encoding.
def get_error_details(exclude_robot_traces=EXCLUDE_ROBOT_TRACES)
Returns error message and details of the last occurred exception.