本文整理汇总了Python中translate.storage.versioncontrol.run_command函数的典型用法代码示例。如果您正苦于以下问题:Python run_command函数的具体用法?Python run_command怎么用?Python run_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run_command函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例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
示例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
示例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
示例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
示例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
示例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)
示例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)
示例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
示例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)
示例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)
示例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
示例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