Пример #1
0
    def fake_clone_func(self, directory, name):
        directory = Path(directory)
        if not directory.is_dir():
            raise ReleaseException(
                f"Cannot clone into non-existent directory {directory}:")

        shell_command(directory, f"fedpkg clone {name!r} --anonymous",
                      "Cloning fedora repository failed:")
        return str(directory / name)
Пример #2
0
 def set_credentials(self, name, email):
     """
     Sets credentials fo git repo to keep git from resisting to commit
     :param name: committer name
     :param email: committer email
     :return: True on success False on fail
     """
     email = shell_command(self.repo_path, f'git config user.email "{email}"', '', fail=False)
     name = shell_command(self.repo_path, f'git config user.name "{name}"', '', fail=False)
     return email and name
Пример #3
0
    def build_sdist(project_root):
        """
        Builds source distribution out of setup.py

        :param project_root: location of setup.py
        """
        if os.path.isfile(os.path.join(project_root, 'setup.py')):
            shell_command(project_root, "python setup.py sdist",
                          "Cannot build sdist:")
        else:
            raise ReleaseException("Cannot find setup.py:")
Пример #4
0
    def upload(self, project_root):
        """
        Uploads the package distribution to PyPi

        :param project_root: directory with dist/ folder
        """
        if os.path.isdir(os.path.join(project_root, 'dist')):
            spec_files = glob(os.path.join(project_root, "dist/*"))
            files = ""
            for file in spec_files:
                files += f"{file} "
            self.logger.debug(f"Uploading {files} to PyPi")
            shell_command(project_root, f"twine upload {files}",
                          "Cannot upload python distribution:")
        else:
            raise ReleaseException("dist/ folder cannot be found:")
Пример #5
0
    def fedpkg_new_sources(directory, branch, sources="", fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        return shell_command(directory, f"fedpkg new-sources {sources}",
                             f"Adding new sources on branch {branch} failed:",
                             fail)
Пример #6
0
 def checkout_new_branch(self, branch):
     """
     Creates a new local branch
     :param branch: branch name
     :return: True on success False on fail
     """
     return shell_command(self.repo_path, f'git checkout -b "{branch}"', '', fail=False)
Пример #7
0
    def fedpkg_sources(directory, branch, fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        return shell_command(
            directory, "fedpkg sources",
            f"Retrieving sources for branch {branch} failed:", fail)
Пример #8
0
    def fedpkg_merge(directory, branch, ff_only=True, fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        return shell_command(
            directory, f"git merge master {'--ff-only' if ff_only else ''}",
            f"Merging master to branch {branch!r} failed:", fail)
Пример #9
0
    def fedpkg_push(directory, branch, fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        return shell_command(directory, "fedpkg push",
                             f"Pushing branch {branch!r} to Fedora failed:",
                             fail)
Пример #10
0
    def fedpkg_spectool(directory, branch, fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        spec_files = glob(os.path.join(directory, "*spec"))
        spec_files = " ".join(spec_files)
        return shell_command(directory, f"spectool -g {spec_files}",
                             f"Retrieving new sources for branch {branch} failed:", fail)
Пример #11
0
 def push(self, branch):
     """
     Executes git push
     :param branch: branch to push
     :return:
     """
     success = shell_command(self.repo_path, f'git push origin {branch}', '', False)
     if not success:
         raise GitException(f"Can't push branch {branch} to origin!")
Пример #12
0
    def fedpkg_clone_repository(directory, name):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot clone fedpkg repository into non-existent directory:")

        if shell_command(directory, f"fedpkg clone {name!r}",
                         "Cloning fedora repository failed:"):
            return os.path.join(directory, name)
        else:
            return ''
Пример #13
0
 def init_ticket(keytab, fas_username):
     if not fas_username:
         return False
     if keytab and os.path.isfile(keytab):
         cmd = f"kinit {fas_username}@FEDORAPROJECT.ORG -k -t {keytab}"
     else:
         # there is no keytab, but user still migh have active ticket - try to renew it
         cmd = f"kinit -R {fas_username}@FEDORAPROJECT.ORG"
     return shell_command(os.getcwd(), cmd, "Failed to init kerberos ticket:", False)
Пример #14
0
 def add(self, files: list):
     """
     Executes git add
     :param files: list of files to add
     :return:
     """
     for file in files:
         success = shell_command(self.repo_path, f'git add {file}', '', False)
         if not success:
             raise GitException(f"Can't git add file {file}!")
Пример #15
0
 def commit(self, message='release commit', allow_empty=False):
     """
     Executes git commit
     :param message: commit message
     :return:
     """
     arg = '--allow-empty' if allow_empty else ''
     success = shell_command(self.repo_path, f'git commit {arg} -m \"{message}\"', '', False)
     if not success:
         raise GitException(f"Can't commit files!")
Пример #16
0
    def build_wheel(project_root, python_version):
        """
        Builds wheel for specified version of python

        :param project_root: location of setup.py
        :param python_version: python version to build wheel for
        """
        interpreter = "python2"
        if python_version == 3:
            interpreter = "python3"
        elif python_version != 2:
            # no other versions of python other than 2 and three are supported
            raise ReleaseException(
                f"Unsupported python version: {python_version}")

        if not os.path.isfile(os.path.join(project_root, 'setup.py')):
            raise ReleaseException("Cannot find setup.py:")

        shell_command(project_root, f"{interpreter} setup.py bdist_wheel",
                      f"Cannot build wheel for python {python_version}")
Пример #17
0
 def clone(url):
     """
     Clones repository from url to temporary directory
     :param url:
     :return: TemporaryDirectory object
     """
     temp_directory = TemporaryDirectory()
     if not shell_command(temp_directory.name, f'git clone {url} .',
                          "Couldn't clone repository!", fail=False):
         raise GitException(f"Can't clone repository {url}")
     return temp_directory
Пример #18
0
    def fedpkg_build(self, directory, branch, scratch=False, fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        self.logger.debug(f"Building branch {branch!r} in Fedora. It can take a long time.")
        success = shell_command(directory,
                                f"fedpkg build {'--scratch' if scratch else ''}",
                                f"Building branch {branch!r} in Fedora failed:", fail)
        if success:
            self.builds.append(f"{branch}")

        return success
Пример #19
0
    def fedpkg_commit(directory, branch, message, fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        return shell_command(directory, f"fedpkg commit -m '{message}'",
                             f"Committing on branch {branch} failed:", fail)
Пример #20
0
    def fedpkg_switch_branch(directory, branch, fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        return shell_command(directory, f"fedpkg switch-branch {branch}",
                             f"Switching to {branch} failed:", fail)
Пример #21
0
    def fedpkg_lint(directory, branch, fail=True):
        if not os.path.isdir(directory):
            raise ReleaseException("Cannot access fedpkg repository:")

        return shell_command(directory, "fedpkg lint",
                             f"Spec lint on branch {branch} failed:", fail)