本文整理汇总了Python中rebasehelper.base_output.OutputLogger类的典型用法代码示例。如果您正苦于以下问题:Python OutputLogger类的具体用法?Python OutputLogger怎么用?Python OutputLogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OutputLogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_check
def run_check(cls, results_dir):
""" Compares old and new RPMs using pkgdiff """
results_dict = {}
for tag in settings.CHECKER_TAGS:
results_dict[tag] = []
cls.results_dir = results_dir
# Only S (size), M(mode) and 5 (checksum) are now important
not_catched_flags = ['T', 'F', 'G', 'U', 'V', 'L', 'D', 'N']
old_pkgs = cls._get_rpms(OutputLogger.get_build('old').get('rpm', None))
new_pkgs = cls._get_rpms(OutputLogger.get_build('new').get('rpm', None))
for key, value in six.iteritems(old_pkgs):
cmd = [cls.CMD]
# TODO modify to online command
for x in not_catched_flags:
cmd.extend(['-i', x])
cmd.append(value)
# We would like to build correct old package against correct new packages
cmd.append(new_pkgs[key])
output = StringIO()
ProcessHelper.run_subprocess(cmd, output=output)
results_dict = cls._analyze_logs(output, results_dict)
results_dict = cls.update_added_removed(results_dict)
results_dict = dict((k, v) for k, v in six.iteritems(results_dict) if v)
text = []
for key, val in six.iteritems(results_dict):
text.append('Following files were %s:\n%s' % (key, '\n'.join(val)))
return text
示例2: _prepare_spec_objects
def _prepare_spec_objects(self):
"""
Prepare spec files and initialize objects
:return:
"""
self.rebase_spec_file_path = get_rebase_name(self.spec_file_path)
self.spec_file = SpecFile(self.spec_file_path,
self.execution_dir,
download=not self.conf.not_download_sources)
# Check whether test suite is enabled at build time
if not self.spec_file.is_test_suite_enabled():
OutputLogger.set_info_text('WARNING', 'Test suite is not enabled at build time.')
# create an object representing the rebased SPEC file
self.rebase_spec_file = self.spec_file.copy(self.rebase_spec_file_path)
# check if argument passed as new source is a file or just a version
if [True for ext in Archive.get_supported_archives() if self.conf.sources.endswith(ext)]:
logger.debug("argument passed as a new source is a file")
self.rebase_spec_file.set_version_using_archive(self.conf.sources)
else:
logger.debug("argument passed as a new source is a version")
version, extra_version = SpecFile.split_version_string(self.conf.sources)
self.rebase_spec_file.set_version(version)
if extra_version:
self.rebase_spec_file.set_extra_version(extra_version)
示例3: print_summary
def print_summary(cls, path):
"""
Function is used for printing summary informations
:return:
"""
for key, value in six.iteritems(OutputLogger.get_summary_info()):
logger.info("%s %s\n", key, value)
try:
LoggerHelper.add_file_handler(logger_report, path)
except (OSError, IOError):
raise RebaseHelperError("Can not create results file '%s'" % path)
type_pkgs = ['old', 'new']
if OutputLogger.get_patches():
cls.print_patches(OutputLogger.get_patches(), '\nSummary information about patches:')
for pkg in type_pkgs:
type_pkg = OutputLogger.get_build(pkg)
if type_pkg:
cls.print_rpms(type_pkg, pkg.capitalize())
cls.print_build_logs(type_pkg, pkg.capitalize())
cls.print_pkgdiff_tool()
示例4: print_summary
def print_summary(cls, path):
"""
Function is used for printing summary informations
:return:
"""
# First of all we would like to print all
# summary information
OutputLogger.set_info_text("Summary output is also available in log:", path)
logger.info('\n')
for key, value in six.iteritems(OutputLogger.get_summary_info()):
logger.info("%s %s\n", key, value)
try:
LoggerHelper.add_file_handler(logger_output, path)
except (OSError, IOError):
raise RebaseHelperError("Can not create results file '%s'", path)
type_pkgs = ['old', 'new']
cls.print_patches(OutputLogger.get_patches(), '\nSummary information about patches:')
for pkg in type_pkgs:
type_pkg = OutputLogger.get_build(pkg)
if type_pkg:
cls.print_rpms(type_pkg, pkg.capitalize())
cls.print_build_logs(type_pkg, pkg.capitalize())
cls.print_pkgdiff_tool()
示例5: run_check
def run_check(cls, results_dir):
""" Compares old and new RPMs using pkgdiff """
results_dict = {}
for tag in settings.CHECKER_TAGS:
results_dict[tag] = []
cls.results_dir = results_dir
# Only S (size), M(mode) and 5 (checksum) are now important
not_catched_flags = ['T', 'F', 'G', 'U', 'V', 'L', 'D', 'N']
old_pkgs = cls._get_rpms(OutputLogger.get_build('old').get('rpm', None))
new_pkgs = cls._get_rpms(OutputLogger.get_build('new').get('rpm', None))
for key, value in six.iteritems(old_pkgs):
cmd = [cls.CMD]
# TODO modify to online command
for x in not_catched_flags:
cmd.extend(['-i', x])
cmd.append(value)
# We would like to build correct old package against correct new packages
cmd.append(new_pkgs[key])
output = StringIO()
ret_code = ProcessHelper.run_subprocess(cmd, output=output)
results_dict = cls._analyze_logs(output, results_dict)
results_dict = cls.update_added_removed(results_dict)
# TODO Check for changed files and
# remove them from 'removed' and 'added'
#cls._unpack_rpm(old_pkgs)
#cls._unpack_rpm(new_pkgs)
#cls._find_file_diffs(old_pkgs, new_pkgs)
return results_dict
示例6: run_check
def run_check(cls, result_dir):
"""Compares old and new RPMs using pkgdiff"""
debug_old, rest_pkgs_old = cls._get_packages_for_abipkgdiff(OutputLogger.get_build('old'))
debug_new, rest_pkgs_new = cls._get_packages_for_abipkgdiff(OutputLogger.get_build('new'))
cmd = [cls.CMD]
if debug_old is None:
logger.warning("Package doesn't contain any debug package")
return None
try:
cmd.append('--d1')
cmd.append(debug_old[0])
except IndexError:
logger.error('Debuginfo package not found for old package.')
return None
try:
cmd.append('--d2')
cmd.append(debug_new[0])
except IndexError:
logger.error('Debuginfo package not found for new package.')
return None
reports = {}
for pkg in rest_pkgs_old:
command = list(cmd)
# Package can be <letters><numbers>-<letters>-<and_whatever>
regexp = r'^(\w*)(-\D+)?.*$'
reg = re.compile(regexp)
matched = reg.search(os.path.basename(pkg))
if matched:
file_name = matched.group(1)
command.append(pkg)
find = [x for x in rest_pkgs_new if os.path.basename(x).startswith(file_name)]
command.append(find[0])
package_name = os.path.basename(os.path.basename(pkg))
logger.debug('Package name for ABI comparision %s', package_name)
regexp_name = r'(\w-)*(\D+)*'
reg_name = re.compile(regexp_name)
matched = reg_name.search(os.path.basename(pkg))
logger.debug('Found matches %s', matched.groups())
if matched:
package_name = matched.group(0) + cls.log_name
else:
package_name = package_name + '-' + cls.log_name
output = os.path.join(cls.results_dir, result_dir, package_name)
try:
ret_code = ProcessHelper.run_subprocess(command, output=output)
except OSError:
raise CheckerNotFoundError("Checker '%s' was not found or installed." % cls.CMD)
if int(ret_code) & settings.ABIDIFF_ERROR and int(ret_code) & settings.ABIDIFF_USAGE_ERROR:
raise RebaseHelperError('Execution of %s failed.\nCommand line is: %s' % (cls.CMD, cmd))
if int(ret_code) == 0:
text = 'ABI of the compared binaries in package %s are equal.' % package_name
else:
text = 'ABI of the compared binaries in package %s are not equal.' % package_name
reports[output] = text
else:
logger.debug("Rebase-helper did not find a package name in '%s'", package_name)
return reports
示例7: print_pkgdiff_tool
def print_pkgdiff_tool(cls):
"""
Function prints a summary information about pkgcomparetool
"""
if OutputLogger.get_checkers():
for check, data in six.iteritems(OutputLogger.get_checkers()):
if data:
logger_output.info("%s:\n%s", check, data)
示例8: __init__
def __init__(self, cli_conf=None):
"""
Initialize the application
:param cli_conf: CLI object with configuration gathered from commandline
:return:
"""
OutputLogger.clear()
self.conf = cli_conf
if self.conf.verbose:
LoggerHelper.add_stream_handler(logger, logging.DEBUG)
else:
LoggerHelper.add_stream_handler(logger, logging.INFO)
# The directory in which rebase-helper was executed
if self.conf.results_dir is None:
self.execution_dir = os.getcwd()
else:
self.execution_dir = self.conf.results_dir
# Temporary workspace for Builder, checks, ...
self.kwargs['workspace_dir'] = self.workspace_dir = os.path.join(self.execution_dir,
settings.REBASE_HELPER_WORKSPACE_DIR)
# Directory where results should be put
self.kwargs['results_dir'] = self.results_dir = os.path.join(self.execution_dir,
settings.REBASE_HELPER_RESULTS_DIR)
self.kwargs['non_interactive'] = self.conf.non_interactive
# if not continuing, check the results dir
if not self.conf.cont and not self.conf.build_only and not self.conf.comparepkgs:
self._check_results_dir()
# This is used if user executes rebase-helper with --continue
# parameter even when directory does not exist
if not os.path.exists(self.results_dir):
os.makedirs(self.results_dir)
os.makedirs(os.path.join(self.results_dir, settings.REBASE_HELPER_LOGS))
self._add_debug_log_file()
self._add_report_log_file()
logger.debug("Rebase-helper version: %s" % version.VERSION)
if self.conf.build_tasks is None:
self._get_spec_file()
self._prepare_spec_objects()
# check the workspace dir
if not self.conf.cont:
self._check_workspace_dir()
# TODO: Remove the value from kwargs and use only CLI attribute!
self.kwargs['continue'] = self.conf.cont
self._initialize_data()
if self.conf.cont or self.conf.build_only:
self._delete_old_builds()
示例9: get_checker_outputs
def get_checker_outputs(self):
checkers = {}
if OutputLogger.get_checkers():
for check, data in six.iteritems(OutputLogger.get_checkers()):
if data:
for log in six.iterkeys(data):
if FileHelper.file_available(log):
checkers[check] = log
else:
checkers[check] = None
return checkers
示例10: print_pkgdiff_tool
def print_pkgdiff_tool(cls):
"""
Function prints a summary information about pkgcomparetool
"""
if OutputLogger.get_checkers():
for check, data in six.iteritems(OutputLogger.get_checkers()):
if data:
logger_output.info("%s", check)
for checker, output in six.iteritems(data):
logger_output.info("===Checker %s===\n%s\n", checker, '\n'.join(output))
示例11: print_pkgdiff_tool
def print_pkgdiff_tool(cls):
"""
Function prints a summary information about pkgcomparetool
"""
if OutputLogger.get_checkers():
for check, data in six.iteritems(OutputLogger.get_checkers()):
logger_report.info("=== Checker %s results ===", check)
for checker, output in six.iteritems(data):
if output is None:
logger_report.info("Log is available here: %s\n", checker)
else:
logger_report.info("%s See for more details %s", output, checker)
示例12: pkgdiff_packages
def pkgdiff_packages(self):
"""
Function calls pkgdiff class for comparing packages
:return:
"""
try:
pkgchecker = Checker(self.conf.pkgcomparetool)
except NotImplementedError:
raise RebaseHelperError('You have to specify one of these check tools %s', Checker.get_supported_tools())
else:
logger.info('Comparing packages using %s...', self.conf.pkgcomparetool)
results_dict = pkgchecker.run_check(self.results_dir)
for key, val in six.iteritems(results_dict):
if val:
OutputLogger.set_checker_output('Following files were ' + key, '\n'.join(val))
示例13: pkgdiff_packages
def pkgdiff_packages(self):
"""
Function calls pkgdiff class for comparing packages
:return:
"""
pkgdiff_results = {}
if not self.conf.pkgcomparetool:
for checker in Checker.get_supported_tools():
text = self._execute_checkers(checker)
pkgdiff_results[checker] = text
else:
text = self._execute_checkers(self.conf.pkgcomparetool)
pkgdiff_results[self.conf.pkgcomparetool] = text
OutputLogger.set_checker_output('\nResults from checker(s):', pkgdiff_results)
示例14: pkgdiff_packages
def pkgdiff_packages(self):
"""
Function calls pkgdiff class for comparing packages
:return:
"""
pkgdiff_results = {}
if not self.conf.pkgcomparetool:
for checker in Checker.get_supported_tools():
results = self._execute_checkers(checker)
pkgdiff_results[checker] = results
else:
text = self._execute_checkers(self.conf.pkgcomparetool)
pkgdiff_results[self.conf.pkgcomparetool] = text
for diff_name, result in six.iteritems(pkgdiff_results):
OutputLogger.set_checker_output(diff_name, result)
示例15: get_rebased_patches
def get_rebased_patches(self):
"""
Function returns a list of patches either
'': [list_of_deleted_patches]
:return:
"""
patches = False
output_patch_string = []
if OutputLogger.get_patches():
for key, val in six.iteritems(OutputLogger.get_patches()):
if key:
output_patch_string.append('Following patches have been %s:\n%s' % (key, val))
patches = True
if not patches:
output_patch_string.append('Patches were not touched. All were applied properly')
return output_patch_string