コード例 #1
0
 def test_download(self, setup):
     target = os.path.basename(setup["filename"])
     LookasideCacheHelper._download_source(
         setup["tool"], setup["url"], setup["package"], setup["filename"], setup["hashtype"], setup["hash"], target
     )
     assert os.path.isfile(target)
     assert LookasideCacheHelper._hash(target, setup["hashtype"]) == setup["hash"]
コード例 #2
0
    def download_remote_sources(self):
        """
        Method that iterates over all sources and downloads ones, which contain URL instead of just a file.

        :return: None
        """
        try:
            # try to download old sources from Fedora lookaside cache
            LookasideCacheHelper.download('fedpkg', os.path.dirname(self.path),
                                          self.get_package_name())
        except LookasideCacheError as e:
            logger.debug("Downloading sources from lookaside cache failed. "
                         "Reason: '{}'.".format(str(e)))

        # filter out only sources with URL
        remote_files = [
            source for source in self.sources
            if bool(urllib.parse.urlparse(source).scheme)
        ]
        # download any sources that are not yet downloaded
        for remote_file in remote_files:
            local_file = os.path.join(self.sources_location,
                                      os.path.basename(remote_file))
            if not os.path.isfile(local_file):
                logger.debug(
                    "File '%s' doesn't exist locally, downloading it.",
                    local_file)
                try:
                    DownloadHelper.download_file(remote_file, local_file)
                except DownloadError as e:
                    raise RebaseHelperError(
                        "Failed to download file from URL {}. "
                        "Reason: '{}'. ".format(remote_file, str(e)))
コード例 #3
0
    def download_remote_sources(self):
        """
        Method that iterates over all sources and downloads ones, which contain URL instead of just a file.

        :return: None
        """
        try:
            # try to download old sources from Fedora lookaside cache
            LookasideCacheHelper.download('fedpkg', os.path.dirname(self.path), self.get_package_name())
        except LookasideCacheError as e:
            logger.debug("Downloading sources from lookaside cache failed. "
                         "Reason: '{}'.".format(str(e)))

        # filter out only sources with URL
        remote_files = [source for source in self.sources if bool(urllib.parse.urlparse(source).scheme)]
        # download any sources that are not yet downloaded
        for remote_file in remote_files:
            local_file = os.path.join(self.sources_location, os.path.basename(remote_file))
            if not os.path.isfile(local_file):
                logger.debug("File '%s' doesn't exist locally, downloading it.", local_file)
                try:
                    DownloadHelper.download_file(remote_file, local_file)
                except DownloadError as e:
                    raise RebaseHelperError("Failed to download file from URL {}. "
                                            "Reason: '{}'. ".format(remote_file, str(e)))
コード例 #4
0
ファイル: test_utils.py プロジェクト: vcrhonek/rebase-helper
 def test_download(self, package, filename, hashtype, hsh):
     # pylint: disable=protected-access
     target = os.path.basename(filename)
     LookasideCacheHelper._download_source('fedpkg',
                                           'https://integration:4430/pkgs',
                                           package, filename, hashtype, hsh,
                                           target)
     assert os.path.isfile(target)
     assert LookasideCacheHelper._hash(target, hashtype) == hsh
コード例 #5
0
 def test_download(self, setup):
     target = os.path.basename(setup['filename'])
     LookasideCacheHelper._download_source(setup['tool'], setup['url'],
                                           setup['package'],
                                           setup['filename'],
                                           setup['hashtype'], setup['hash'],
                                           target)
     assert os.path.isfile(target)
     assert LookasideCacheHelper._hash(target,
                                       setup['hashtype']) == setup['hash']
コード例 #6
0
ファイル: test_utils.py プロジェクト: FrNecas/rebase-helper
 def test_download(self, package, filename, hashtype, hash):
     target = os.path.basename(filename)
     LookasideCacheHelper._download_source('fedpkg',
                                           'https://src.fedoraproject.org/repo/pkgs',
                                           package,
                                           filename,
                                           hashtype,
                                           hash,
                                           target)
     assert os.path.isfile(target)
     assert LookasideCacheHelper._hash(target, hashtype) == hash
コード例 #7
0
ファイル: application.py プロジェクト: vcrhonek/rebase-helper
    def __init__(self, cli_conf, execution_dir, results_dir, debug_log_file):
        """
        Initialize the application

        :param cli_conf: CLI object with configuration gathered from commandline
        :return:
        """
        results_store.clear()

        self.conf = cli_conf
        self.execution_dir = execution_dir
        self.rebased_sources_dir = os.path.join(results_dir, 'rebased-sources')

        self.debug_log_file = debug_log_file

        # Temporary workspace for Builder, checks, ...
        self.kwargs['workspace_dir'] = self.workspace_dir = os.path.join(self.execution_dir, constants.WORKSPACE_DIR)
        # Directory where results should be put
        self.kwargs['results_dir'] = self.results_dir = results_dir

        # Directory contaning only those files, which are relevant for the new rebased version
        self.kwargs['rebased_sources_dir'] = self.rebased_sources_dir

        self.kwargs['non_interactive'] = self.conf.non_interactive

        self.kwargs['changelog_entry'] = self.conf.changelog_entry

        self.kwargs['spec_hook_blacklist'] = self.conf.spec_hook_blacklist

        logger.debug("Rebase-helper version: %s", VERSION)

        if self.conf.build_tasks is None:
            # check the workspace dir
            if not self.conf.cont:
                self._check_workspace_dir()

            self._get_spec_file()
            self._prepare_spec_objects()

            if self.conf.update_sources:
                sources = [os.path.basename(s) for s in self.spec_file.sources]
                rebased_sources = [os.path.basename(s) for s in self.rebase_spec_file.sources]
                uploaded = LookasideCacheHelper.update_sources('fedpkg', self.rebased_sources_dir,
                                                               self.rebase_spec_file.get_package_name(),
                                                               sources, rebased_sources)
                self._update_gitignore(uploaded, self.rebased_sources_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()