예제 #1
0
    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()
예제 #2
0
    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()
예제 #3
0
    def print_summary(cls, path, results=results_store):
        """
        Function is used for printing summary informations

        :return: 
        """
        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 '%s'" % path)

        type_pkgs = ['old', 'new']
        if results.get_patches():
            cls.print_patches(results.get_patches(),
                              '\nSummary information about patches:')
        for pkg in type_pkgs:
            type_pkg = results.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(results.get_checkers())
예제 #4
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())
예제 #5
0
    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())
예제 #6
0
    def run():
        debug_log_file = None
        try:
            cli = CLI()
            if hasattr(cli, 'version'):
                logger.info(VERSION)
                sys.exit(0)

            config = Config(getattr(cli, 'config-file', None))
            config.merge(cli)
            for handler in [main_handler, output_tool_handler]:
                handler.set_terminal_background(config.background)

            ConsoleHelper.use_colors = ConsoleHelper.should_use_colors(config)
            execution_dir, results_dir, debug_log_file = Application.setup(
                config)
            traceback_log = os.path.join(results_dir, LOGS_DIR, TRACEBACK_LOG)
            if config.verbose == 0:
                main_handler.setLevel(logging.INFO)
            elif config.verbose == 1:
                main_handler.setLevel(CustomLogger.VERBOSE)
            else:
                main_handler.setLevel(logging.DEBUG)
            app = Application(config, execution_dir, results_dir,
                              debug_log_file)
            app.run()
        except KeyboardInterrupt:
            logger.info('Interrupted by user')
        except RebaseHelperError as e:
            if e.msg:
                logger.error('%s', e.msg)
            else:
                logger.error('%s', six.text_type(e))
            sys.exit(1)
        except SystemExit as e:
            sys.exit(e.code)
        except BaseException:
            if debug_log_file:
                logger.error(
                    'rebase-helper failed due to an unexpected error. Please report this problem'
                    '\nusing the following link: %s'
                    '\nand include the content of'
                    '\n\'%s\' and'
                    '\n\'%s\''
                    '\nin the report.'
                    '\nThank you!', NEW_ISSUE_LINK, debug_log_file,
                    traceback_log)
                LoggerHelper.add_file_handler(logger_traceback, traceback_log)
                logger_traceback.trace('', exc_info=1)
            else:
                logger.error(
                    'rebase-helper failed due to an unexpected error. Please report this problem'
                    '\nusing the following link: %s'
                    '\nThank you!', NEW_ISSUE_LINK)
            sys.exit(1)

        sys.exit(0)
예제 #7
0
    def run():
        debug_log_file = None
        try:
            cli = CLI()
            if hasattr(cli, 'version'):
                logger.info(VERSION)
                sys.exit(0)

            config = Config(getattr(cli, 'config-file', None))
            config.merge(cli)
            for handler in [main_handler, output_tool_handler]:
                handler.set_terminal_background(config.background)

            ConsoleHelper.use_colors = ConsoleHelper.should_use_colors(config)
            execution_dir, results_dir, debug_log_file = Application.setup(config)
            traceback_log = os.path.join(results_dir, LOGS_DIR, TRACEBACK_LOG)
            if config.verbose == 0:
                main_handler.setLevel(logging.INFO)
            elif config.verbose == 1:
                main_handler.setLevel(CustomLogger.VERBOSE)
            else:
                main_handler.setLevel(logging.DEBUG)
            app = Application(config, execution_dir, results_dir, debug_log_file)
            app.run()
        except KeyboardInterrupt:
            logger.info('Interrupted by user')
        except RebaseHelperError as e:
            if e.msg:
                logger.error('%s', e.msg)
            else:
                logger.error('%s', str(e))
            sys.exit(1)
        except SystemExit as e:
            sys.exit(e.code)
        except BaseException:
            if debug_log_file:
                logger.error('rebase-helper failed due to an unexpected error. Please report this problem'
                             '\nusing the following link: %s'
                             '\nand include the content of'
                             '\n\'%s\' and'
                             '\n\'%s\''
                             '\nin the report.'
                             '\nThank you!',
                             NEW_ISSUE_LINK, debug_log_file, traceback_log)
                LoggerHelper.add_file_handler(logger_traceback, traceback_log)
                logger_traceback.trace('', exc_info=1)
            else:
                logger.error('rebase-helper failed due to an unexpected error. Please report this problem'
                             '\nusing the following link: %s'
                             '\nThank you!',
                             NEW_ISSUE_LINK)
            sys.exit(1)

        sys.exit(0)
예제 #8
0
    def _add_report_log_file(results_dir):
        """
        Add the application report log file

        :return: log file path
        """
        report_log_file = os.path.join(results_dir,
                                       settings.REBASE_HELPER_REPORT_LOG)
        try:
            LoggerHelper.add_file_handler(logger_report, report_log_file, None,
                                          logging.INFO)
        except (IOError, OSError):
            logger.warning("Can not create report log '%s'", report_log_file)
        else:
            return report_log_file
예제 #9
0
 def _add_report_log_file(self):
     """
     Add the application report log file
     :return:
     """
     report_log_file = os.path.join(self.results_dir, settings.REBASE_HELPER_REPORT_LOG)
     try:
         LoggerHelper.add_file_handler(logger_report,
                                       report_log_file,
                                       None,
                                       logging.INFO)
     except (IOError, OSError):
         logger.warning("Can not create report log '%s'", report_log_file)
     else:
         self.report_log_file = report_log_file
예제 #10
0
 def _add_debug_log_file(self):
     """
     Add the application wide debug log file
     :return:
     """
     debug_log_file = os.path.join(self.results_dir, settings.REBASE_HELPER_DEBUG_LOG)
     try:
         LoggerHelper.add_file_handler(logger,
                                       debug_log_file,
                                       logging.Formatter("%(asctime)s %(levelname)s\t%(filename)s"
                                                         ":%(lineno)s %(funcName)s: %(message)s"),
                                       logging.DEBUG)
     except (IOError, OSError):
         logger.warning("Can not create debug log '%s'", debug_log_file)
     else:
         self.debug_log_file = debug_log_file
예제 #11
0
    def _add_debug_log_file(results_dir):
        """
        Add the application wide debug log file

        :return: log file path
        """
        debug_log_file = os.path.join(results_dir, constants.DEBUG_LOG)
        try:
            LoggerHelper.add_file_handler(logger,
                                          debug_log_file,
                                          logging.Formatter("%(asctime)s %(levelname)s\t%(filename)s"
                                                            ":%(lineno)s %(funcName)s: %(message)s"),
                                          logging.DEBUG)
        except (IOError, OSError):
            logger.warning("Can not create debug log '%s'", debug_log_file)
        else:
            return debug_log_file
예제 #12
0
    def print_summary(cls, report_path, results):
        """Outputs a summary of a rebase.

        Args:
            report_path: Where the report file should be created
            results: ResultsStore instance to get data from.

        """
        info = results.get_summary_info()
        if info:
            for key, value in info.items():
                level = logging.getLevelName(key)
                if isinstance(level, int):
                    logger.log(level, value)
                else:
                    logger.info('%s: %s', key, value)

        LoggerHelper.add_file_handler(logger_report, report_path)

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

        cls.print_changes_patch(results)

        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())
예제 #13
0
    def setup_logging(results_dir):
        """Adds file handlers of various verbosity to loggers.

        Args:
            results_dir: Path to directory which results are stored in.

        Returns:
            string: Path to debug log.

        """
        logs_dir = os.path.join(results_dir, constants.LOGS_DIR)
        debug_log = os.path.join(logs_dir, constants.DEBUG_LOG)
        LoggerHelper.add_file_handler(logger, debug_log, debug_log_formatter, logging.DEBUG)
        verbose_log = os.path.join(logs_dir, constants.VERBOSE_LOG)
        LoggerHelper.add_file_handler(logger, verbose_log, log_formatter, CustomLogger.VERBOSE)
        info_log = os.path.join(logs_dir, constants.INFO_LOG)
        LoggerHelper.add_file_handler(logger, info_log, log_formatter, logging.INFO)

        return debug_log
예제 #14
0
    def setup_logging(results_dir):
        """Adds file handlers of various verbosity to loggers.

        Args:
            results_dir: Path to directory which results are stored in.

        Returns:
            string: Path to debug log.

        """
        logs_dir = os.path.join(results_dir, constants.LOGS_DIR)
        debug_log = os.path.join(logs_dir, constants.DEBUG_LOG)
        LoggerHelper.add_file_handler(logger, debug_log, debug_log_formatter, logging.DEBUG)
        verbose_log = os.path.join(logs_dir, constants.VERBOSE_LOG)
        LoggerHelper.add_file_handler(logger, verbose_log, log_formatter, CustomLogger.VERBOSE)
        info_log = os.path.join(logs_dir, constants.INFO_LOG)
        LoggerHelper.add_file_handler(logger, info_log, log_formatter, logging.INFO)

        return debug_log
예제 #15
0
    def run(cls):
        results_dir = None
        start_dir = os.getcwd()
        try:
            LoggerHelper.setup_memory_handler()
            main_handler, output_tool_handler = LoggerHelper.create_stream_handlers(
            )
            cli = CLI()
            if hasattr(cli, 'version'):
                print(VERSION)
                sys.exit(0)

            logger.info('rebase-helper version %s', VERSION)

            config = Config(getattr(cli, 'config-file', None))
            config.merge(cli)
            for handler in [main_handler, output_tool_handler]:
                handler.set_terminal_background(config.background)
            if config.verbose == 0:
                main_handler.setLevel(logging.INFO)
            elif config.verbose == 1:
                main_handler.setLevel(CustomLogger.VERBOSE)
            else:
                main_handler.setLevel(logging.DEBUG)
            ConsoleHelper.use_colors = ConsoleHelper.should_use_colors(config)
            if config.bugzilla_id:
                repo_path, config.config[
                    'sources'] = BugzillaHelper.prepare_rebase_repository(
                        config.bugzilla_id)
                try:
                    os.chdir(repo_path)
                except OSError as e:
                    raise RebaseHelperError(
                        'Could not change directory to the cloned repository'
                    ) from e
                # update relative paths in config
                for option in ('results_dir', 'workspace_dir'):
                    path = getattr(config, option)
                    if path and not os.path.isabs(path):
                        config.config[option] = os.path.join(
                            os.path.relpath(start_dir, os.getcwd()), path)

            if config.config['rpmmacros']:
                macros = ' -D ' + ' -D '.join(
                    '"{}"'.format(s) for s in config.config['rpmmacros'])
                for option in ('builder_options', 'srpm_builder_options'):
                    if config.config[option]:
                        config.config[option] += macros
                    else:
                        config.config[option] = macros

            config.config['rpmmacros'] = cls.convert_macros_to_dict(
                config.rpmmacros)
            execution_dir, results_dir = Application.setup(config)
            app = Application(config, start_dir, execution_dir, results_dir)
            app.run()
        except KeyboardInterrupt:
            logger.info('Interrupted by user')
        except RebaseHelperError as e:
            if e.msg:
                logger.error('%s', e.msg)
            else:
                logger.error('%s', str(e))
            sys.exit(1)
        except SystemExit as e:
            sys.exit(e.code)
        except BaseException:
            logger_traceback: CustomLogger = cast(
                CustomLogger, logging.getLogger('rebasehelper.traceback'))
            logger_traceback.propagate = False
            logger_traceback.setLevel(CustomLogger.TRACE)
            if results_dir:
                debug_log = os.path.join(results_dir, LOGS_DIR, DEBUG_LOG)
                traceback_log = os.path.join(results_dir, LOGS_DIR,
                                             TRACEBACK_LOG)
                logger.error(
                    'rebase-helper failed due to an unexpected error. Please report this problem'
                    '\nusing the following link: %s'
                    '\nand include the content of'
                    '\n\'%s\' and'
                    '\n\'%s\''
                    '\nin the report.'
                    '\nThank you!', NEW_ISSUE_LINK, debug_log, traceback_log)
                LoggerHelper.add_file_handler(logger_traceback, traceback_log)
            else:
                logger.error(
                    'rebase-helper failed due to an unexpected error. Please report this problem'
                    '\nusing the following link: %s'
                    '\nand include the following traceback in the report.'
                    '\nThank you!', NEW_ISSUE_LINK)

                LoggerHelper.add_stream_handler(logger_traceback,
                                                CustomLogger.TRACE)
            logger_traceback.trace('', exc_info=1)
            sys.exit(1)

        sys.exit(0)