Beispiel #1
0
    def print_summary(cls, path, results):
        """Function is used for printing summary information"""
        if results.get_summary_info():
            for key, value in results.get_summary_info().items():
                logger.info("%s %s\n", key, value)

        LoggerHelper.add_file_handler(logger_report, path)

        cls.results_store = results

        cls.print_success_message()
        logger_report.info("All result files are stored in %s", os.path.dirname(path))

        cls.print_changes_patch()

        cls.print_checkers_text_output(results.get_checkers())

        cls.print_build_log_hooks_result(results.get_build_log_hooks())

        if results.get_patches():
            cls.print_patches(results.get_patches())

        cls.print_message_and_separator("\nRPMS")
        for pkg_version in ['old', 'new']:
            pkg_results = results.get_build(pkg_version)
            if pkg_results:
                cls.print_rpms_and_logs(pkg_results, pkg_version.capitalize())
Beispiel #2
0
 def print_build_logs(cls, rpms, version):
     """Function is used for printing rpm build logs"""
     if rpms.get('logs', None) is None:
         return
     logger_report.info('Available %s logs:', version)
     for logs in rpms.get('logs', None):
         logger_report.info('- %s', logs)
Beispiel #3
0
 def print_success_message(cls):
     """Print result message"""
     results = cls.results_store.get_result_message()
     if 'success' in results:
         logger_report.info(results['success'])
     else:
         logger_report.info(results['fail'])
    def print_summary(cls, path, results):
        """Function is used for printing summary information"""
        if results.get_summary_info():
            for key, value in six.iteritems(results.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 '{}'".format(path))

        cls.results_store = results

        cls.print_success_message()
        logger_report.info("All result files are stored in %s",
                           os.path.dirname(path))

        cls.print_changes_patch()

        cls.print_checkers_text_output(results.get_checkers())

        if results.get_patches():
            cls.print_patches(results.get_patches())

        cls.print_message_and_separator("\nRPMS")
        for pkg_version in ['old', 'new']:
            pkg_results = results.get_build(pkg_version)
            if pkg_results:
                cls.print_rpms_and_logs(pkg_results, pkg_version.capitalize())
Beispiel #5
0
 def print_success_message(cls):
     """Print result message"""
     results = cls.results_store.get_result_message()
     if 'success' in results:
         logger_report.info(results['success'])
     else:
         logger_report.info(results['fail'])
 def print_build_log_hooks_result(cls, build_log_hooks_result):
     for hook, data in six.iteritems(build_log_hooks_result):
         if data:
             cls.print_message_and_separator(
                 '\n{} build log hook'.format(hook))
             logger_report.info('\n'.join(
                 build_log_hook_runner.build_log_hooks[hook].format(data)))
Beispiel #7
0
 def print_checkers_text_output(cls, checkers_results):
     """Function prints text output for every checker"""
     for check_tool in cls.manager.checkers.plugins.values():
         if check_tool:
             for check, data in sorted(checkers_results.items()):
                 if check == check_tool.name:
                     logger_report.info('\n'.join(check_tool.format(data)))
Beispiel #8
0
 def print_changes_patch(cls):
     """Print info about the location of changes.patch"""
     patch = cls.results_store.get_changes_patch()
     if patch is not None:
         logger_report.info(
             '\nPatch with differences between old and new version source files:'
         )
         logger_report.info(patch['changes_patch'])
 def print_build_logs(cls, rpms, dirpath):
     """Function is used for printing rpm build logs"""
     if rpms.get('logs', None) is None:
         return
     for logs in sorted(rpms.get('logs', []) + rpms.get('srpm_logs', [])):
         if dirpath not in logs:
             # Skip logs that do not belong to curent rpms(and version)
             continue
         logger_report.info(' - %s', os.path.basename(logs))
Beispiel #10
0
 def print_build_logs(cls, rpms, dirpath):
     """Function is used for printing rpm build logs"""
     if rpms.get('logs', None) is None:
         return
     for logs in sorted(rpms.get('logs', []) + rpms.get('srpm_logs', [])):
         if dirpath not in logs:
             # Skip logs that do not belong to curent rpms(and version)
             continue
         logger_report.info(' - %s', os.path.basename(logs))
Beispiel #11
0
    def print_build_logs(cls, rpms, version):
        """
        Function is used for printing rpm build logs

        :param kwargs: 
        :return: 
        """
        if rpms.get('logs', None) is None:
            return
        logger_report.info('Available %s logs:', version)
        for logs in rpms.get('logs', None):
            logger_report.info('- %s', logs)
Beispiel #12
0
 def print_pkgdiff_tool(cls, checkers_results):
     """Function prints a summary information about pkgcomparetool"""
     if checkers_results:
         for check, data in six.iteritems(checkers_results):
             logger_report.info("=== Checker %s results ===", check)
             if data:
                 for checker, output in six.iteritems(data):
                     if output is None:
                         logger_report.info("Log is available here: %s\n", checker)
                     else:
                         if isinstance(output, list):
                             logger_report.info("%s See for more details %s", ','.join(output), checker)
                         else:
                             logger_report.info("%s See for more details %s", output, checker)
Beispiel #13
0
 def print_rpms(cls, rpms, version):
     pkgs = ['srpm', 'rpm']
     if not rpms.get('srpm', None):
         return
     message = '\n{0} (S)RPM packages:'.format(version)
     cls.print_message_and_separator(message=message, separator='-')
     for type_rpm in pkgs:
         srpm = rpms.get(type_rpm, None)
         if not srpm:
             continue
         message = "%s package(s): are in directory %s :"
         if isinstance(srpm, str):
             logger_report.info(message, type_rpm.upper(), os.path.dirname(srpm))
             logger_report.info("- %s", os.path.basename(srpm))
         else:
             logger_report.info(message, type_rpm.upper(), os.path.dirname(srpm[0]))
             for pkg in srpm:
                 logger_report.info("- %s", os.path.basename(pkg))
    def print_rpms_and_logs(cls, rpms, version):
        """
        Prints information about location of RPMs and logs created during rebase
        :param rpms: dictionary of (S)RPM paths
        :param version: new/old version string
        :return:
        """
        pkgs = ['srpm', 'rpm']
        if not rpms.get('rpm', None):
            return
        message = '\n{} packages'.format(version)
        cls.print_message_and_separator(message=message, separator='-')
        for type_rpm in pkgs:
            srpm = rpms.get(type_rpm, None)
            if not srpm:
                continue

            if type_rpm == 'srpm':
                message = "\nSource packages and logs are in directory %s:"
            else:
                message = "\nBinary packages and logs are in directory %s:"

            if isinstance(srpm, str):
                # Print SRPM path
                dirname = os.path.dirname(srpm)
                logger_report.info(
                    message,
                    cls.prepend_results_dir_name(version.lower() + '-build',
                                                 'SRPM'))
                logger_report.info(" - %s", os.path.basename(srpm))
                # Print SRPM logs
                cls.print_build_logs(rpms, dirname)

            else:
                # Print RPMs paths
                dirname = os.path.dirname(srpm[0])
                logger_report.info(
                    message,
                    cls.prepend_results_dir_name(version.lower() + '-build',
                                                 'RPM'))
                for pkg in sorted(srpm):
                    logger_report.info(" - %s", os.path.basename(pkg))
                # Print RPMs logs
                cls.print_build_logs(rpms, dirname)
Beispiel #15
0
 def print_pkgdiff_tool(cls, checkers_results):
     """Function prints a summary information about pkgcomparetool"""
     if checkers_results:
         for check, data in six.iteritems(checkers_results):
             logger_report.info("=== Checker %s results ===", check)
             if data:
                 for checker, output in six.iteritems(data):
                     if output is None:
                         logger_report.info("Log is available here: %s\n",
                                            checker)
                     else:
                         if isinstance(output, list):
                             logger_report.info(
                                 "%s See for more details %s",
                                 ','.join(output), checker)
                         else:
                             logger_report.info(
                                 "%s See for more details %s", output,
                                 checker)
Beispiel #16
0
 def print_rpms(cls, rpms, version):
     pkgs = ['srpm', 'rpm']
     if not rpms.get('srpm', None):
         return
     message = '\n{0} (S)RPM packages:'.format(version)
     cls.print_message_and_separator(message=message, separator='-')
     for type_rpm in pkgs:
         srpm = rpms.get(type_rpm, None)
         if not srpm:
             continue
         message = "%s package(s): are in directory %s :"
         if isinstance(srpm, str):
             logger_report.info(message, type_rpm.upper(),
                                os.path.dirname(srpm))
             logger_report.info("- %s", os.path.basename(srpm))
         else:
             logger_report.info(message, type_rpm.upper(),
                                os.path.dirname(srpm[0]))
             for pkg in srpm:
                 logger_report.info("- %s", os.path.basename(pkg))
Beispiel #17
0
    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)
Beispiel #18
0
    def print_rpms_and_logs(cls, rpms, version):
        """
        Prints information about location of RPMs and logs created during rebase
        :param rpms: dictionary of (S)RPM paths
        :param version: new/old version string
        :return:
        """
        pkgs = ['srpm', 'rpm']
        if not rpms.get('rpm', None):
            return
        message = '\n{} packages'.format(version)
        cls.print_message_and_separator(message=message, separator='-')
        for type_rpm in pkgs:
            srpm = rpms.get(type_rpm, None)
            if not srpm:
                continue

            if type_rpm == 'srpm':
                message = "\nSource packages and logs are in directory %s:"
            else:
                message = "\nBinary packages and logs are in directory %s:"

            if isinstance(srpm, str):
                # Print SRPM path
                dirname = os.path.dirname(srpm)
                logger_report.info(message, cls.prepend_results_dir_name(version.lower() + '-build', 'SRPM'))
                logger_report.info(" - %s", os.path.basename(srpm))
                # Print SRPM logs
                cls.print_build_logs(rpms, dirname)

            else:
                # Print RPMs paths
                dirname = os.path.dirname(srpm[0])
                logger_report.info(message, cls.prepend_results_dir_name(version.lower() + '-build', 'RPM'))
                for pkg in sorted(srpm):
                    logger_report.info(" - %s", os.path.basename(pkg))
                # Print RPMs logs
                cls.print_build_logs(rpms, dirname)
Beispiel #19
0
 def print_patches(cls, patches, summary):
     if not patches:
         logger_report.info("Patches were neither modified nor deleted.")
         return
     logger_report.info(summary)
     max_name = 0
     for value in six.itervalues(patches):
         if value:
             new_max = max([len(os.path.basename(x)) for x in value])
             if new_max > max_name:
                 max_name = new_max
     max_key = max([len(x) for x in six.iterkeys(patches)])
     for key, value in six.iteritems(patches):
         if value:
             for patch in value:
                 logger_report.info('Patch %s [%s]', os.path.basename(patch).ljust(max_name), key.ljust(max_key))
Beispiel #20
0
 def print_patches(cls, patches, summary):
     if not patches:
         logger_report.info("Patches were neither modified nor deleted.")
         return
     logger_report.info(summary)
     max_name = 0
     for value in six.itervalues(patches):
         if value:
             new_max = max([len(os.path.basename(x)) for x in value])
             if new_max > max_name:
                 max_name = new_max
     max_key = max([len(x) for x in six.iterkeys(patches)])
     for key, value in six.iteritems(patches):
         if value:
             for patch in value:
                 logger_report.info('Patch %s [%s]',
                                    os.path.basename(patch).ljust(max_name),
                                    key.ljust(max_key))
Beispiel #21
0
 def print_message_and_separator(cls, message="", separator='='):
     logger_report.info(message)
     logger_report.info(separator * len(message))
 def print_checkers_text_output(cls, checkers_results):
     """Function prints text output for every checker"""
     for check_tool in six.itervalues(checkers_runner.plugin_classes):
         for check, data in sorted(six.iteritems(checkers_results)):
             if check == check_tool.get_checker_name():
                 logger_report.info('\n'.join(check_tool.format(data)))
    def print_patches(cls, patches):
        cls.print_message_and_separator("\nDownstream Patches")
        if not patches:
            logger_report.info("Patches were neither modified nor deleted.")
            return

        logger_report.info("Rebased patches are located in %s",
                           cls.prepend_results_dir_name('rebased-sources'))
        logger_report.info("Legend:")
        logger_report.info("[-] = already applied, patch removed")
        logger_report.info("[*] = merged, patch modified")
        logger_report.info("[!] = conflicting or inapplicable, patch skipped")
        logger_report.info("[ ] = patch untouched")

        patches_out = list()
        for patch_type, patch_list in sorted(six.iteritems(patches)):
            if patch_list:
                symbols = dict(deleted='-', modified='*', inapplicable='!')
                for patch in sorted(patch_list):
                    patches_out.append(' * {0:40} [{1}]'.format(
                        os.path.basename(patch), symbols.get(patch_type, ' ')))
        logger_report.info('\n'.join(sorted(patches_out)))
Beispiel #24
0
    def print_patches(cls, patches):
        cls.print_message_and_separator("\nDownstream Patches")
        if not patches:
            logger_report.info("Patches were neither modified nor deleted.")
            return

        logger_report.info("Rebased patches are located in %s", cls.prepend_results_dir_name('rebased-sources'))
        logger_report.info("Legend:")
        logger_report.info("[-] = already applied, patch removed")
        logger_report.info("[*] = merged, patch modified")
        logger_report.info("[!] = conflicting or inapplicable, patch skipped")
        logger_report.info("[ ] = patch untouched")

        patches_out = list()
        for patch_type, patch_list in sorted(patches.items()):
            if patch_list:
                symbols = dict(deleted='-', modified='*', inapplicable='!')
                for patch in sorted(patch_list):
                    patches_out.append(' * {0:40} [{1}]'.format(os.path.basename(patch),
                                                                symbols.get(patch_type, ' ')))
        logger_report.info('\n'.join(sorted(patches_out)))
Beispiel #25
0
 def print_message_and_separator(cls, message="", separator='='):
     logger_report.info(message)
     logger_report.info(separator * (len(message) - 1))
Beispiel #26
0
 def print_changes_patch(cls):
     """Print info about the location of changes.patch"""
     patch = cls.results_store.get_changes_patch()
     if patch is not None:
         logger_report.info('\nPatch with differences between old and new version source files:')
         logger_report.info(cls.prepend_results_dir_name(os.path.basename(patch['changes_patch'])))
Beispiel #27
0
 def print_build_log_hooks_result(cls, build_log_hooks_result):
     for hook, data in build_log_hooks_result.items():
         if data:
             cls.print_message_and_separator('\n{} build log hook'.format(hook))
             logger_report.info('\n'.join(cls.manager.build_log_hooks.get_plugin(hook).format(data)))