How to use the rebasehelper.logger.CustomLogger function in rebasehelper

To help you get started, we’ve selected a few rebasehelper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / rpminspect_srpm.py View on Github external
#          Nikola Forró 
#          František Nečas 

import logging
import os

from typing import Optional, cast

from rebasehelper.logger import CustomLogger
from rebasehelper.results_store import results_store
from rebasehelper.helpers.rpm_helper import RpmHelper
from rebasehelper.plugins.checkers import CheckerCategory
from rebasehelper.plugins.checkers.rpminspect import Rpminspect


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))


class RpminspectSrpm(Rpminspect):
    """SRPM rpminspect checker."""

    CATEGORY: Optional[CheckerCategory] = CheckerCategory.SRPM

    @classmethod
    def run_check(cls, results_dir, **kwargs):
        cls.results_dir = os.path.join(results_dir, 'rpminspect-srpm')
        cls.prepare_results_dir()

        result = {'path': cls.get_checker_output_dir_short(), 'files': [], 'checks': {}}
        old_pkg = results_store.get_old_build()['srpm']
        new_pkg = results_store.get_new_build()['srpm']
        name = RpmHelper.split_nevra(os.path.basename(old_pkg))['name']
github rebase-helper / rebase-helper / rebasehelper / plugins / build_tools / rpm / copr_.py View on Github external
#          Nikola Forró 
#          František Nečas 

import logging
import os
from typing import cast

from rebasehelper.helpers.copr_helper import CoprHelper
from rebasehelper.types import Options
from rebasehelper.logger import CustomLogger
from rebasehelper.exceptions import RebaseHelperError
from rebasehelper.plugins.build_tools.rpm import BuildToolBase
from rebasehelper.exceptions import BinaryPackageBuildError


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))


class Copr(BuildToolBase):
    """
    Class representing Copr build tool.
    """

    OPTIONS: Options = [
        {
            'name': ['--copr-project-permanent'],
            'switch': True,
            'default': False,
            'help': 'make the created copr project permanent'
        },
        {
            'name': ['--copr-project-frontpage'],
github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / abipkgdiff.py View on Github external
#          František Nečas 

import logging
import os
import re
from typing import Dict, Optional, cast

from rebasehelper.exceptions import RebaseHelperError, CheckerNotFoundError
from rebasehelper.logger import CustomLogger
from rebasehelper.results_store import results_store
from rebasehelper.plugins.checkers import BaseChecker, CheckerCategory
from rebasehelper.helpers.process_helper import ProcessHelper
from rebasehelper.helpers.rpm_helper import RpmHelper


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))

AbiChange = Dict[str, Dict[str, Dict[str, str]]]


class AbiPkgDiff(BaseChecker):
    """abipkgdiff compare tool."""

    DEFAULT: bool = True
    CATEGORY: Optional[CheckerCategory] = CheckerCategory.RPM
    results_dir: Optional[str] = ''

    CMD: str = 'abipkgdiff'
    ABIDIFF_ERROR: int = 1 << 0
    ABIDIFF_USAGE_ERROR: int = 1 << 1
    ABIDIFF_ABI_CHANGE: int = 1 << 2
    ABIDIFF_ABI_INCOMPATIBLE_CHANGE: int = 1 << 3
github rebase-helper / rebase-helper / rebasehelper / helpers / download_helper.py View on Github external
import logging
import os
import sys
import time
import urllib.error
import urllib.request
from typing import cast

import requests

from rebasehelper.exceptions import DownloadError
from rebasehelper.logger import CustomLogger


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))


class DownloadHelper:

    """Class for downloading files and performing HTTP requests."""

    @staticmethod
    def progress(download_total, downloaded, start_time):
        """Prints current progress and estimated remaining time of a download to the standard output.

        Args:
            download_total (int): Total download size in bytes.
            downloaded (int): Size of the already downloaded portion of a file in bytes.
            start_time (float): Time when the download started in seconds since epoch.

        """
github rebase-helper / rebase-helper / rebasehelper / plugins / build_tools / rpm / rpmbuild.py View on Github external
import logging
import os
from typing import cast

from rebasehelper.helpers.process_helper import ProcessHelper
from rebasehelper.helpers.input_helper import InputHelper
from rebasehelper.helpers.path_helper import PathHelper
from rebasehelper.helpers.rpm_helper import RpmHelper
from rebasehelper.logger import CustomLogger
from rebasehelper.plugins.build_tools import RpmbuildTemporaryEnvironment
from rebasehelper.plugins.build_tools.rpm import BuildToolBase
from rebasehelper.exceptions import RebaseHelperError, BinaryPackageBuildError


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))


class Rpmbuild(BuildToolBase):  # pylint: disable=abstract-method
    """
    Class representing rpmbuild build tool.
    """

    ACCEPTS_OPTIONS: bool = True

    CMD: str = 'rpmbuild'

    @classmethod
    def _build_rpm(cls, srpm, workdir, results_dir, rpm_results_dir, builder_options=None):
        """Builds RPMs using rpmbuild

        Args:
github rebase-helper / rebase-helper / rebasehelper / plugins / spec_hooks / commit_hash_updater.py View on Github external
#
# Authors: Petr Hráček 
#          Tomáš Hozza 
#          Nikola Forró 
#          František Nečas 

import logging
import re
from typing import cast

from rebasehelper.logger import CustomLogger
from rebasehelper.plugins.spec_hooks import BaseSpecHook
from rebasehelper.helpers.download_helper import DownloadHelper


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))


class CommitHashUpdater(BaseSpecHook):
    """Tries to update commit hash present in Source0 tag according to the new version"""

    @classmethod
    def _get_commit_hash_from_github(cls, spec_file):
        """
        Tries to find a commit using Github API

        :param spec_file: SPEC file to base the search on
        :return: SHA of a commit, or None
        """
        m = re.match(r'^https?://github\.com/(?P[\w-]+)/(?P[\w-]+)/.*$', spec_file.sources[0])
        if not m:
            return None
github rebase-helper / rebase-helper / rebasehelper / logger.py View on Github external
def log(message, *args, **kwargs):
            if self.isEnabledFor(severity):
                self._log(severity, message, args, **kwargs)

        if severity:
            return log

        raise AttributeError


class ColorizingStreamHandler(logging.StreamHandler):
    colors: Dict[str, Dict[int, Dict[str, Optional[str]]]] = {
        'dark': {
            logging.DEBUG: {'fg': 'brightblack', 'bg': 'default', 'style': None},
            CustomLogger.TRACE: {'fg': 'red', 'bg': 'default', 'style': None},
            CustomLogger.VERBOSE: {'fg': 'brightblack', 'bg': 'default', 'style': None},
            logging.INFO: {'fg': 'default', 'bg': 'default', 'style': None},
            CustomLogger.SUCCESS: {'fg': 'green', 'bg': 'default', 'style': None},
            CustomLogger.HEADING: {'fg': 'yellow', 'bg': 'default', 'style': None},
            CustomLogger.IMPORTANT: {'fg': 'red', 'bg': 'default', 'style': None},
            logging.WARNING: {'fg': 'yellow', 'bg': 'default', 'style': None},
            logging.ERROR: {'fg': 'red', 'bg': 'default', 'style': 'bold'},
            logging.CRITICAL: {'fg': 'white', 'bg': 'red', 'style': 'bold'},
        },
        'light': {
            logging.DEBUG: {'fg': 'brightblack', 'bg': 'default', 'style': None},
            CustomLogger.TRACE: {'fg': 'red', 'bg': 'default', 'style': None},
            CustomLogger.VERBOSE: {'fg': 'brightblack', 'bg': 'default', 'style': None},
            logging.INFO: {'fg': 'default', 'bg': 'default', 'style': None},
            CustomLogger.SUCCESS: {'fg': 'green', 'bg': 'default', 'style': None},
            CustomLogger.HEADING: {'fg': 'blue', 'bg': 'default', 'style': None},
            CustomLogger.IMPORTANT: {'fg': 'red', 'bg': 'default', 'style': None},
github rebase-helper / rebase-helper / rebasehelper / cli.py View on Github external
from typing import cast, Dict, List

from rebasehelper import VERSION
from rebasehelper.options import OPTIONS, traverse_options
from rebasehelper.constants import PROGRAM_DESCRIPTION, NEW_ISSUE_LINK, LOGS_DIR, TRACEBACK_LOG, DEBUG_LOG
from rebasehelper.application import Application
from rebasehelper.logger import CustomLogger, LoggerHelper
from rebasehelper.exceptions import RebaseHelperError
from rebasehelper.helpers.console_helper import ConsoleHelper
from rebasehelper.helpers.bugzilla_helper import BugzillaHelper
from rebasehelper.config import Config
from rebasehelper.argument_parser import CustomArgumentParser, CustomHelpFormatter, CustomAction
from rebasehelper.plugins.plugin_manager import plugin_manager


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))


class CLI:
    """ Class for processing data from commandline """

    @staticmethod
    def build_parser(available_choices_only=False):
        parser = CustomArgumentParser(description=PROGRAM_DESCRIPTION,
                                      formatter_class=CustomHelpFormatter)

        group = None
        current_group = 0
        for option in traverse_options(OPTIONS + plugin_manager.get_options()):
            available_choices = option.pop("available_choices", option.get("choices"))
            if available_choices_only:
                option["choices"] = available_choices
github rebase-helper / rebase-helper / rebasehelper / plugins / versioneers / __init__.py View on Github external
#
# Authors: Petr Hráček 
#          Tomáš Hozza 
#          Nikola Forró 
#          František Nečas 

import logging
from typing import cast

from rebasehelper.logger import CustomLogger
from rebasehelper.plugins.plugin import Plugin
from rebasehelper.plugins.plugin_collection import PluginCollection
from rebasehelper.types import PackageCategories


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))


class BaseVersioneer(Plugin):
    """Base class for a versioneer"""

    CATEGORIES: PackageCategories = []

    @classmethod
    def run(cls, package_name):
        """
        Runs a versioneer.

        :param package_name: Name of a package
        :return: Latest upstream version of a package
        """
        raise NotImplementedError()
github rebase-helper / rebase-helper / rebasehelper / plugins / build_tools / srpm / rpmbuild.py View on Github external
#          Nikola Forró 
#          František Nečas 

import logging
import os
from typing import cast

from rebasehelper.logger import CustomLogger
from rebasehelper.plugins.build_tools import RpmbuildTemporaryEnvironment
from rebasehelper.plugins.build_tools.srpm import SRPMBuildToolBase
from rebasehelper.helpers.path_helper import PathHelper
from rebasehelper.helpers.process_helper import ProcessHelper
from rebasehelper.exceptions import SourcePackageBuildError


logger: CustomLogger = cast(CustomLogger, logging.getLogger(__name__))


class Rpmbuild(SRPMBuildToolBase):

    DEFAULT: bool = True

    CMD: str = 'rpmbuild'

    @classmethod
    def _build_srpm(cls, spec, workdir, results_dir, srpm_results_dir, srpm_builder_options):
        """Builds SRPM using rpmbuild.

        Args:
            spec: Path to SPEC file to build the SRPM from.
            workdir: Path to working directory with rpmbuild directory structure.
            results_dir: Path to directory where logs will be placed.