本文整理汇总了Python中avocado.core.output.LOG_UI类的典型用法代码示例。如果您正苦于以下问题:Python LOG_UI类的具体用法?Python LOG_UI怎么用?Python LOG_UI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LOG_UI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self, args):
if args.distro_def_create:
if not (args.distro_def_name and args.distro_def_version and
args.distro_def_arch and args.distro_def_type and
args.distro_def_path):
LOG_UI.error('Required arguments: name, version, arch, type '
'and path')
sys.exit(exit_codes.AVOCADO_FAIL)
output_file_name = self.get_output_file_name(args)
if os.path.exists(output_file_name):
error_msg = ('Output file "%s" already exists, will not '
'overwrite it', output_file_name)
LOG_UI.error(error_msg)
else:
LOG_UI.debug("Loading distro information from tree... "
"Please wait...")
distro = load_from_tree(args.distro_def_name,
args.distro_def_version,
args.distro_def_release,
args.distro_def_arch,
args.distro_def_type,
args.distro_def_path)
save_distro(distro, output_file_name)
LOG_UI.debug('Distro information saved to "%s"',
output_file_name)
else:
detected = utils_distro.detect()
LOG_UI.debug('Detected distribution: %s (%s) version %s release '
'%s', detected.name, detected.arch, detected.version,
detected.release)
示例2: run
def run(self, args):
"""
Print libexec path and finish
:param args: Command line args received from the run subparser.
"""
LOG_UI.debug(resource_filename("avocado", "libexec"))
示例3: initialize
def initialize(self, args):
self.variants = None
cit_parameter_file = getattr(args, "cit_parameter_file", None)
if cit_parameter_file is None:
return
else:
cit_parameter_file = os.path.expanduser(cit_parameter_file)
if not os.access(cit_parameter_file, os.R_OK):
LOG_UI.error("parameter file '%s' could not be found or "
"is not readable", cit_parameter_file)
self.error_exit(args)
config = configparser.ConfigParser()
try:
config.read(cit_parameter_file)
except Exception as details:
LOG_UI.error("Cannot parse parameter file: %s", details)
self.error_exit(args)
parameters = [(key, value.split(', '))
for key, value in config.items('parameters')]
order = args.cit_order_of_combinations
cit = Cit(parameters, order)
self.headers, self.variants = cit.combine()
示例4: test_progress
def test_progress(self, progress=False):
if not self.owns_stdout:
return
if progress:
color = output.TERM_SUPPORT.PASS
else:
color = output.TERM_SUPPORT.PARTIAL
LOG_UI.debug(color + self.__throbber.render() +
output.TERM_SUPPORT.ENDC, extra={"skip_newline": True})
示例5: post_tests
def post_tests(self, job):
if not self.owns_stdout:
return
if job.status == 'PASS':
LOG_UI.info("RESULTS : PASS %d | ERROR %d | FAIL %d | SKIP %d | "
"WARN %d | INTERRUPT %s | CANCEL %s", job.result.passed,
job.result.errors, job.result.failed, job.result.skipped,
job.result.warned, job.result.interrupted,
job.result.cancelled)
示例6: run
def run(self, args):
"""
Print libexec path and finish
:param args: Command line args received from the run subparser.
"""
system_wide = '/usr/libexec/avocado'
if os.path.isdir(system_wide):
LOG_UI.debug(system_wide)
else:
LOG_UI.debug(resource_filename("avocado", "libexec"))
示例7: end_test
def end_test(self, result, state):
if not self.owns_stdout:
return
status = state.get("status", "ERROR")
if status == "TEST_NA":
status = "SKIP"
duration = (" (%.2f s)" % state.get('time_elapsed', -1)
if status != "SKIP"
else "")
msg = self.get_colored_status(status, state.get("fail_reason", None))
LOG_UI.debug(msg + duration)
示例8: _get_test_suite
def _get_test_suite(self, paths):
if self.args.verbose:
which_tests = loader.DiscoverMode.ALL
else:
which_tests = loader.DiscoverMode.AVAILABLE
try:
return loader.loader.discover(paths,
which_tests=which_tests)
except loader.LoaderUnhandledReferenceError as details:
LOG_UI.error(str(details))
sys.exit(exit_codes.AVOCADO_FAIL)
示例9: start_test
def start_test(self, result, state):
if not self.owns_stdout:
return
if "name" in state:
name = state["name"]
uid = name.str_uid
name = name.name + name.str_variant
else:
name = "<unknown>"
uid = '?'
LOG_UI.debug(' (%s/%s) %s: ', uid, result.tests_total, name,
extra={"skip_newline": True})
示例10: end_test
def end_test(self, result, state):
if not self.owns_stdout:
return
status = state.get("status", "ERROR")
if status == "TEST_NA":
status = "SKIP"
duration = (" (%.2f s)" % state.get('time_elapsed', -1)
if status != "SKIP"
else "")
LOG_UI.debug(output.TERM_SUPPORT.MOVE_BACK +
self.output_mapping[status] +
status + output.TERM_SUPPORT.ENDC +
duration)
示例11: initialize
def initialize(self, args):
load_variants = getattr(args, "json_variants_load", None)
if load_variants is None:
self.variants = _NO_VARIANTS
return
try:
with open(load_variants, 'r') as var_file:
self.variants = varianter.Varianter(state=json.load(var_file))
except IOError:
LOG_UI.error("JSON serialized file '%s' could not be found or "
"is not readable", load_variants)
if args.subcommand == 'run':
sys.exit(exit_codes.AVOCADO_JOB_FAIL)
else:
sys.exit(exit_codes.AVOCADO_FAIL)
示例12: mail
def mail(self, job):
# build proper subject based on job status
subject = '%s Job %s - Status: %s' % (self.subject,
job.unique_id,
job.status)
msg = MIMEText(subject)
msg['Subject'] = self.subject
msg['From'] = self.sender
msg['To'] = self.rcpt
# So many possible failures, let's just tell the user about it
try:
smtp = smtplib.SMTP(self.server)
smtp.sendmail(self.sender, [self.rcpt], msg.as_string())
smtp.quit()
except:
LOG_UI.error("Failure to send email notification: "
"please check your mail configuration")
示例13: _check_required_args
def _check_required_args(args, enable_arg, required_args):
"""
:return: True when enable_arg enabled and all required args are set
:raise sys.exit: When missing required argument.
"""
if (not hasattr(args, enable_arg) or
not getattr(args, enable_arg)):
return False
missing = []
for arg in required_args:
if not getattr(args, arg):
missing.append(arg)
if missing:
LOG_UI.error("Use of %s requires %s arguments to be set. Please "
"set %s.", enable_arg, ', '.join(required_args),
', '.join(missing))
return sys.exit(exit_codes.AVOCADO_FAIL)
return True
示例14: run
def run(self, args):
"""
Run test modules or simple tests.
:param args: Command line args received from the run subparser.
"""
if 'output_check_record' in args:
process.OUTPUT_CHECK_RECORD_MODE = getattr(args,
'output_check_record',
None)
if args.unique_job_id is not None:
try:
int(args.unique_job_id, 16)
if len(args.unique_job_id) != 40:
raise ValueError
except ValueError:
LOG_UI.error('Unique Job ID needs to be a 40 digit hex number')
sys.exit(exit_codes.AVOCADO_FAIL)
try:
args.job_timeout = time_to_seconds(args.job_timeout)
except ValueError as detail:
LOG_UI.error(detail.args[0])
sys.exit(exit_codes.AVOCADO_FAIL)
with job.Job(args) as job_instance:
pre_post_dispatcher = JobPrePostDispatcher()
try:
# Run JobPre plugins
output.log_plugin_failures(pre_post_dispatcher.load_failures)
pre_post_dispatcher.map_method('pre', job_instance)
job_run = job_instance.run()
finally:
# Run JobPost plugins
pre_post_dispatcher.map_method('post', job_instance)
result_dispatcher = ResultDispatcher()
if result_dispatcher.extensions:
result_dispatcher.map_method('render',
job_instance.result,
job_instance)
return job_run
示例15: render
def render(self, result, job):
if not (hasattr(job.args, 'xunit_job_result') or
hasattr(job.args, 'xunit_output')):
return
if not result.tests_total:
return
content = self._render(result)
if getattr(job.args, 'xunit_job_result', 'off') == 'on':
xunit_path = os.path.join(job.logdir, 'results.xml')
with open(xunit_path, 'w') as xunit_file:
xunit_file.write(content)
xunit_path = getattr(job.args, 'xunit_output', 'None')
if xunit_path is not None:
if xunit_path == '-':
LOG_UI.debug(content)
else:
with open(xunit_path, 'w') as xunit_file:
xunit_file.write(content)