• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python versioncontrol.run_command函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中translate.storage.versioncontrol.run_command函数的典型用法代码示例。如果您正苦于以下问题:Python run_command函数的具体用法?Python run_command怎么用?Python run_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了run_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: update

    def update(self, revision=None, needs_revert=True):
        """Does a clean update of the given path

        :param revision: ignored for hg
        """
        output_revert = ""
        if needs_revert:
            # revert local changes (avoids conflicts)
            command = ["hg", "-R", self.root_dir, "revert",
                    "--all", self.location_abs]
            exitcode, output_revert, error = run_command(command)
            if exitcode != 0:
                raise IOError("[Mercurial] error running '%s': %s" %
                              (command, error))

        # pull new patches
        command = ["hg", "-R", self.root_dir, "pull"]
        exitcode, output_pull, error = run_command(command)
        if exitcode != 0:
            raise IOError("[Mercurial] error running '%s': %s" %
                          (command, error))
        # update working directory
        command = ["hg", "-R", self.root_dir, "update"]
        exitcode, output_update, error = run_command(command)
        if exitcode != 0:
            raise IOError("[Mercurial] error running '%s': %s" %
                          (command, error))
        return output_revert + output_pull + output_update
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:28,代码来源:hg.py


示例2: commit

 def commit(self, message=None, author=None, add=True):
     """Commits the file and supplies the given commit message if present"""
     # add the file
     output_add = ""
     if add:
         command = self._get_git_command(["add", self.location_rel])
         exitcode, output_add, error = run_command(command, self.root_dir)
         if exitcode != 0:
             raise IOError("[GIT] add of ('%s', '%s') failed: %s" \
                     % (self.root_dir, self.location_rel, error))
     # commit file
     command = self._get_git_command(["commit"])
     if message:
         command.extend(["-m", message])
     if author:
         command.extend(["--author", author])
     exitcode, output_commit, error = run_command(command, self.root_dir)
     if exitcode != 0:
         if len(error):
             msg = error
         else:
             msg = output_commit
         raise IOError("[GIT] commit of ('%s', '%s') failed: %s" \
                 % (self.root_dir, self.location_rel, msg))
     # push changes
     command = self._get_git_command(["push"])
     exitcode, output_push, error = run_command(command, self.root_dir)
     if exitcode != 0:
         raise IOError("[GIT] push of ('%s', '%s') failed: %s" \
                 % (self.root_dir, self.location_rel, error))
     return output_add + output_commit + output_push
开发者ID:andynicholson,项目名称:translate,代码行数:31,代码来源:git.py


示例3: update

 def update(self, revision=None):
     """Does a clean update of the given path"""
     # git checkout
     command = self._get_git_command(["checkout", self.location_rel])
     exitcode, output_checkout, error = run_command(command, self.root_dir)
     if exitcode != 0:
         raise IOError("[GIT] checkout failed (%s): %s" % (command, error))
     # pull changes
     command = self._get_git_command(["pull"])
     exitcode, output_pull, error = run_command(command, self.root_dir)
     if exitcode != 0:
         raise IOError("[GIT] pull failed (%s): %s" % (command, error))
     return output_checkout + output_pull
开发者ID:andynicholson,项目名称:translate,代码行数:13,代码来源:git.py


示例4: update

 def update(self, revision=None):
     """Does a clean update of the given path"""
     # bzr revert
     command = ["bzr", "revert", self.location_abs]
     exitcode, output_revert, error = run_command(command)
     if exitcode != 0:
         raise IOError("[BZR] revert of '%s' failed: %s" \
                 % (self.location_abs, error))
     # bzr pull
     command = ["bzr", "pull"]
     exitcode, output_pull, error = run_command(command)
     if exitcode != 0:
         raise IOError("[BZR] pull of '%s' failed: %s" \
                 % (self.location_abs, error))
     return output_revert + output_pull
开发者ID:davedash,项目名称:translate,代码行数:15,代码来源:bzr.py


示例5: update

 def update(self, revision=None, needs_revert=True):
     """Does a clean update of the given path"""
     #TODO: take needs_revert parameter into account
     working_dir = os.path.dirname(self.location_abs)
     filename = self.location_abs
     filename_backup = filename + os.path.extsep + "bak"
     # rename the file to be updated
     try:
         os.rename(filename, filename_backup)
     except OSError as error:
         raise IOError("[CVS] could not move the file '%s' to '%s': %s" % (
                       filename, filename_backup, error))
     command = ["cvs", "-Q", "update", "-C"]
     if revision:
         command.extend(["-r", revision])
     # the filename is the last argument
     command.append(os.path.basename(filename))
     # run the command within the given working_dir
     exitcode, output, error = run_command(command, working_dir)
     # restore backup in case of an error - remove backup for success
     try:
         if exitcode != 0:
             os.rename(filename_backup, filename)
         else:
             os.remove(filename_backup)
     except OSError:
         pass
     # raise an error or return successfully - depending on the CVS command
     if exitcode != 0:
         raise IOError("[CVS] Error running CVS command '%s': %s" %
                       (command, error))
     else:
         return output
开发者ID:anderson916,项目名称:translate,代码行数:33,代码来源:cvs.py


示例6: update

    def update(self, revision=None):
        """Does a clean update of the given path

        :param revision: ignored for darcs
        """
        # revert local changes (avoids conflicts)
        command = ["darcs", "revert", "--repodir", self.root_dir,
                "-a", self.location_rel]
        exitcode, output_revert, error = run_command(command)
        if exitcode != 0:
            raise IOError("[Darcs] error running '%s': %s" % (command, error))
        # pull new patches
        command = ["darcs", "pull", "--repodir", self.root_dir, "-a"]
        exitcode, output_pull, error = run_command(command)
        if exitcode != 0:
            raise IOError("[Darcs] error running '%s': %s" % (command, error))
        return output_revert + output_pull
开发者ID:davedash,项目名称:translate,代码行数:17,代码来源:darcs.py


示例7: getcleanfile

 def getcleanfile(self, revision=None):
     """Get a clean version of a file from the git repository"""
     # run git-show
     command = self._get_git_command(["show", "HEAD:%s" % self.location_rel])
     exitcode, output, error = run_command(command, self.root_dir)
     if exitcode != 0:
         raise IOError("[GIT] 'show' failed for ('%s', %s): %s" \
                 % (self.root_dir, self.location_rel, error))
     return output
开发者ID:andynicholson,项目名称:translate,代码行数:9,代码来源:git.py


示例8: getcleanfile

 def getcleanfile(self, revision=None):
     """Get a clean version of a file from the bzr repository"""
     # bzr cat
     command = ["bzr", "cat", self.location_abs]
     exitcode, output, error = run_command(command)
     if exitcode != 0:
         raise IOError("[BZR] cat failed for '%s': %s" % (
                       self.location_abs, error))
     return output
开发者ID:anderson916,项目名称:translate,代码行数:9,代码来源:bzr.py


示例9: get_version

def get_version():
    """return a tuple of (major, minor) for the installed subversion client"""
    command = ["svn", "--version", "--quiet"]
    exitcode, output, error = run_command(command)
    if exitcode == 0:
        major, minor = output.strip().split(".")[0:2]
        if (major.isdigit() and minor.isdigit()):
            return (int(major), int(minor))
    # something went wrong above
    return (0, 0)
开发者ID:AndryulE,项目名称:kitsune,代码行数:10,代码来源:svn.py


示例10: get_version

def get_version():
    """return a tuple of (major, minor) for the installed subversion client"""
    exitcode, output, error = run_command(["p4", "-V"])
    
    if exitcode == 0:
        major, minor = output.strip().split("/")[2].split(".")[:2]
        if (major.isdigit() and minor.isdigit()):
            return (int(major), int(minor))
    # something went wrong above
    return (0, 0)
开发者ID:jbeaurain,项目名称:translate-versioncontrol-p4,代码行数:10,代码来源:p4.py


示例11: getcleanfile

 def getcleanfile(self, revision=None):
     """Get a clean version of a file from the hg repository"""
     # run hg cat
     command = ["hg", "-R", self.root_dir, "cat",
             self.location_abs]
     exitcode, output, error = run_command(command)
     if exitcode != 0:
         raise IOError("[Mercurial] Error running '%s': %s" \
                 % (command, error))
     return output
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:10,代码来源:hg.py


示例12: add

    def add(self, files, message=None, author=None):
        """Add and commit the new files."""
        args = ["add"] + prepare_filelist(files)
        command = self._get_git_command(args)
        exitcode, output, error = run_command(command, self.root_dir)
        if exitcode != 0:
            raise IOError("[GIT] add of files in '%s') failed: %s" \
                    % (self.root_dir, error))

        return output + self.commit(message, author, add=False)
开发者ID:andynicholson,项目名称:translate,代码行数:10,代码来源:git.py


示例13: add

    def add(self, files, message=None, author=None):
        """Add and commit the new files."""
        command = ["hg", "add", "-q", "--parents"] + prepare_filelist(files)
        exitcode, output, error = run_command(command)
        if exitcode != 0:
            raise IOError("[Mercurial] Error running '%s': %s" % (command, error))

        # go down as deep as possible in the tree to avoid accidental commits
        # TODO: explicitly commit files by name
        youngest_ancestor = os.path.commonprefix(files)
        return output + type(self)(youngest_ancestor).commit(message, author)
开发者ID:davedash,项目名称:translate,代码行数:11,代码来源:hg.py


示例14: update

 def update(self, revision=None):
     """update the working copy - remove local modifications if necessary"""
     # revert the local copy (remove local changes)
     command = ["svn", "revert", self.location_abs]
     exitcode, output_revert, error = run_command(command)
     # any errors?
     if exitcode != 0:
         raise IOError("[SVN] Subversion error running '%s': %s" \
                 % (command, error))
     # update the working copy to the given revision
     command = ["svn", "update"]
     if not revision is None:
         command.extend(["-r", revision])
     # the filename is the last argument
     command.append(self.location_abs)
     exitcode, output_update, error = run_command(command)
     if exitcode != 0:
         raise IOError("[SVN] Subversion error running '%s': %s" \
                 % (command, error))
     return output_revert + output_update
开发者ID:AndryulE,项目名称:kitsune,代码行数:20,代码来源:svn.py


示例15: getcleanfile

 def getcleanfile(self, revision=None):
     """return the content of the 'head' revision of the file"""
     command = ["svn", "cat"]
     if not revision is None:
         command.extend(["-r", revision])
     # the filename is the last argument
     command.append(self.location_abs)
     exitcode, output, error = run_command(command)
     if exitcode != 0:
         raise IOError("[SVN] Subversion error running '%s': %s" % (command, error))
     return output
开发者ID:AndryulE,项目名称:kitsune,代码行数:11,代码来源:svn.py


示例16: update

 def update(self, revision=None):
     """update the working copy - remove local modifications if necessary"""
     # revert the local copy (remove local changes)
     command = ["p4", "revert", self.location_abs]
     exitcode, output_revert, error = run_command(command)
     # any errors?
     if exitcode != 0:
         raise IOError("[P4] Perforce error running '%s': %s" \
                 % (command, error))
     # update the working copy to the given revision
     command = ["p4", "sync"]
     if not revision is None:
         command.append(self.location_abs + "@" + revision)
     if not revision is None:
         command.append(self.location_abs)
     exitcode, output_update, error = run_command(command)
     if exitcode != 0:
         raise IOError("[P4] Perforce error running '%s': %s" \
                 % (command, error))
     return output_revert + output_update
开发者ID:jbeaurain,项目名称:translate-versioncontrol-p4,代码行数:20,代码来源:p4.py


示例17: add

    def add(self, files, message=None, author=None):
        """Add and commit files."""
        command = ["bzr", "add"] + prepare_filelist(files)
        exitcode, output, error = run_command(command)
        if exitcode != 0:
            raise IOError("[BZR] add in '%s' failed: %s" \
                    % (self.location_abs, error))

        # go down as deep as possible in the tree to avoid accidental commits
        # TODO: explicitly commit files by name
        youngest_ancestor = os.path.commonprefix(files)
        return output + type(self)(youngest_ancestor).commit(message, author)
开发者ID:davedash,项目名称:translate,代码行数:12,代码来源:bzr.py


示例18: add

    def add(self, files, message=None, author=None):
        """Add and commit files."""
        command = ["darcs", "add", "--repodir", self.root_dir] + prepare_filelist(files)
        exitcode, output, error = run_command(command)
        if exitcode != 0:
            raise IOError("[Darcs] Error running darcs command '%s': %s" \
                    % (command, error))

        # go down as deep as possible in the tree to avoid accidental commits
        # TODO: explicitly commit files by name
        youngest_ancestor = os.path.commonprefix(files)
        return output + type(self)(youngest_ancestor).commit(message, author)
开发者ID:davedash,项目名称:translate,代码行数:12,代码来源:darcs.py


示例19: commit

 def commit(self, message=None, author=None):
     """Commits the file and supplies the given commit message if present"""
     if message is None:
         message = ""
     # commit changes
     command = ["hg", "-R", self.root_dir, "commit", "-m", message]
     # add the 'author' argument, if it was given (only supported since v1.0)
     if author and (get_version() >= (1, 0)):
         command.extend(["--user", author])
     # the location is the last argument
     command.append(self.location_abs)
     exitcode, output_commit, error = run_command(command)
     if exitcode != 0:
         raise IOError("[Mercurial] Error running '%s': %s" \
                 % (command, error))
     # push changes
     command = ["hg", "-R", self.root_dir, "push"]
     exitcode, output_push, error = run_command(command)
     if exitcode != 0:
         raise IOError("[Mercurial] Error running '%s': %s" \
                 % (command, error))
     return output_commit + output_push
开发者ID:AndreasEisele,项目名称:wikitrans-pootle,代码行数:22,代码来源:hg.py


示例20: add

    def add(self, files, message=None, author=None):
        """Add and commit the new files."""
        files = prepare_filelist(files)
        command = ["svn", "add", "-q", "--non-interactive", "--parents"] + files
        exitcode, output, error = run_command(command)
        if exitcode != 0:
            raise IOError("[SVN] Error running SVN command '%s': %s" %
                          (command, error))

        # go down as deep as possible in the tree to avoid accidental commits
        # TODO: explicitly commit files by name
        ancestor = youngest_ancestor(files)
        return output + type(self)(ancestor).commit(message, author)
开发者ID:ANKIT-KS,项目名称:fjord,代码行数:13,代码来源:svn.py



注:本文中的translate.storage.versioncontrol.run_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xliff.xlifffile函数代码示例发布时间:2022-05-27
下一篇:
Python ts2.tsfile函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap