本文整理汇总了Python中subprocess2.check_call函数的典型用法代码示例。如果您正苦于以下问题:Python check_call函数的具体用法?Python check_call怎么用?Python check_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_check_call_nonzero
def test_check_call_nonzero(self):
# check_call() function with non-zero return code
try:
subprocess.check_call([sys.executable, "-c",
"import sys; sys.exit(47)"])
except subprocess.CalledProcessError, e:
self.assertEqual(e.returncode, 47)
开发者ID:lelou6666,项目名称:PySOL,代码行数:7,代码来源:test_subprocess2.py
示例2: main
def main(args):
default_args = git.config_list('depot-tools.upstream-diff.default-args')
args = default_args + args
parser = argparse.ArgumentParser()
parser.add_argument('--wordwise', action='store_true', default=False,
help=(
'Print a colorized wordwise diff '
'instead of line-wise diff'))
opts, extra_args = parser.parse_known_args(args)
cur = git.current_branch()
if not cur or cur == 'HEAD':
print 'fatal: Cannot perform git-upstream-diff while not on a branch'
return 1
par = git.upstream(cur)
if not par:
print 'fatal: No upstream configured for branch \'%s\'' % cur
return 1
cmd = [git.GIT_EXE, 'diff', '--patience', '-C', '-C']
if opts.wordwise:
cmd += ['--word-diff=color', r'--word-diff-regex=(\w+|[^[:space:]])']
cmd += [git.get_or_create_merge_base(cur, par)]
cmd += extra_args
subprocess2.check_call(cmd)
开发者ID:CoherentLabs,项目名称:depot_tools,代码行数:29,代码来源:git_upstream_diff.py
示例3: testBlinkDEPSChangeUsingGit
def testBlinkDEPSChangeUsingGit(self):
"""Like testBlinkDEPSChangeUsingGclient, but move the main project using
directly git and not gclient sync."""
if not self.enabled:
return
self.gclient(['config', '--spec',
'solutions=['
'{"name": "src",'
' "url": "' + self.git_base + 'repo_1",'
' "managed": False,'
'}]'])
# Perform an initial sync to bootstrap the repo.
res = self.gclient(['sync', '--jobs', '1'])
self.assertEqual(res[2], 0, 'Initial gclient sync failed.')
# Go back and forth two times.
for _ in xrange(2):
subprocess2.check_call(['git', 'checkout', '-q', self.pre_merge_sha],
cwd=self.checkout_path)
res = self.gclient(['sync', '--jobs', '1'])
self.assertEqual(res[2], 0, 'gclient sync failed.')
self.CheckStatusPreMergePoint()
subprocess2.check_call(['git', 'checkout', '-q', self.post_merge_sha],
cwd=self.checkout_path)
res = self.gclient(['sync', '--jobs', '1'])
self.assertEqual(res[2], 0, 'DEPS change sync failed.')
self.CheckStatusPostMergePoint()
开发者ID:withtone,项目名称:depot_tools,代码行数:30,代码来源:gclient_smoketest.py
示例4: populateSvn
def populateSvn(self):
"""Creates a few revisions of changes files."""
subprocess2.check_call(
['svn', 'checkout', self.svn_base, self.svn_checkout, '-q',
'--non-interactive', '--no-auth-cache',
'--username', self.USERS[0][0], '--password', self.USERS[0][1]])
assert os.path.isdir(os.path.join(self.svn_checkout, '.svn'))
fs = {}
fs['trunk/origin'] = '[email protected]'
fs['trunk/codereview.settings'] = (
'# Test data\n'
'bar: pouet\n')
fs['trunk/svn_utils_test.txt'] = (
'a\n'
'bb\n'
'ccc\n'
'dd\n'
'e\n'
'ff\n'
'ggg\n'
'hh\n'
'i\n'
'jj\n'
'kkk\n'
'll\n'
'm\n'
'nn\n'
'ooo\n'
'pp\n'
'q\n')
self._commit_svn(fs)
fs['trunk/origin'] = '[email protected]\n'
fs['trunk/extra'] = 'dummy\n'
fs['trunk/bin_file'] = '\x00'
self._commit_svn(fs)
开发者ID:lexuanquyen,项目名称:chromium_base,代码行数:35,代码来源:checkout_test.py
示例5: set_up_git
def set_up_git(self):
"""Creates git repositories and start the servers."""
self.set_up()
if self.gitdaemon:
return True
assert self.git_pid_file == None
try:
subprocess2.check_output(["git", "--version"])
except (OSError, subprocess2.CalledProcessError):
return False
for repo in ["repo_%d" % r for r in range(1, self.NB_GIT_REPOS + 1)]:
subprocess2.check_call(["git", "init", "-q", join(self.git_root, repo)])
self.git_hashes[repo] = [None]
self.git_port = find_free_port(self.host, 20000)
self.git_base = "git://%s:%d/git/" % (self.host, self.git_port)
# Start the daemon.
self.git_pid_file = tempfile.NamedTemporaryFile()
cmd = [
"git",
"daemon",
"--export-all",
"--reuseaddr",
"--base-path=" + self.root_dir,
"--pid-file=" + self.git_pid_file.name,
"--port=%d" % self.git_port,
]
if self.host == "127.0.0.1":
cmd.append("--listen=" + self.host)
self.check_port_is_free(self.git_port)
self.gitdaemon = subprocess2.Popen(cmd, cwd=self.root_dir, stdout=subprocess2.PIPE, stderr=subprocess2.PIPE)
wait_for_port_to_bind(self.host, self.git_port, self.gitdaemon)
self.populateGit()
self.git_dirty = False
return True
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:34,代码来源:fake_repos.py
示例6: commit_git
def commit_git(repo):
"""Commits the changes and returns the new hash."""
subprocess2.check_call(["git", "add", "-A", "-f"], cwd=repo)
subprocess2.check_call(["git", "commit", "-q", "--message", "foo"], cwd=repo)
rev = subprocess2.check_output(["git", "show-ref", "--head", "HEAD"], cwd=repo).split(" ", 1)[0]
logging.debug("At revision %s" % rev)
return rev
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:7,代码来源:fake_repos.py
示例7: set_up_svn
def set_up_svn(self):
"""Creates subversion repositories and start the servers."""
self.set_up()
if self.svnserve:
return True
try:
subprocess2.check_call(["svnadmin", "create", self.svn_repo])
except (OSError, subprocess2.CalledProcessError):
return False
write(
join(self.svn_repo, "conf", "svnserve.conf"),
"[general]\n" "anon-access = read\n" "auth-access = write\n" "password-db = passwd\n",
)
text = "[users]\n"
text += "".join("%s = %s\n" % (usr, pwd) for usr, pwd in self.USERS)
write(join(self.svn_repo, "conf", "passwd"), text)
# Mac 10.6 ships with a buggy subversion build and we need this line
# to work around the bug.
write(join(self.svn_repo, "db", "fsfs.conf"), "[rep-sharing]\n" "enable-rep-sharing = false\n")
# Start the daemon.
self.svn_port = find_free_port(self.host, 10000)
logging.debug("Using port %d" % self.svn_port)
cmd = ["svnserve", "-d", "--foreground", "-r", self.root_dir, "--listen-port=%d" % self.svn_port]
if self.host == "127.0.0.1":
cmd.append("--listen-host=" + self.host)
self.check_port_is_free(self.svn_port)
self.svnserve = subprocess2.Popen(cmd, cwd=self.svn_repo, stdout=subprocess2.PIPE, stderr=subprocess2.PIPE)
wait_for_port_to_bind(self.host, self.svn_port, self.svnserve)
self.svn_base = "svn://%s:%d/svn/" % (self.host, self.svn_port)
self.populateSvn()
self.svn_dirty = False
return True
开发者ID:zhiqiang-li,项目名称:chromium_base,代码行数:34,代码来源:fake_repos.py
示例8: testBlinkLocalBranchesArePreserved
def testBlinkLocalBranchesArePreserved(self):
"""Checks that the state of local git branches are effectively preserved
when going back and forth."""
if not self.enabled:
return
self.gclient(['config', '--spec',
'solutions=['
'{"name": "src",'
' "url": "' + self.git_base + 'repo_1",'
'}]'])
# Initialize to pre-merge point.
self.gclient(['sync', '--revision', '[email protected]%s' % self.pre_merge_sha])
self.CheckStatusPreMergePoint()
# Create a branch named "foo".
subprocess2.check_call(['git', 'checkout', '-qB', 'foo'],
cwd=self.blink)
# Cross the pre-merge point.
self.gclient(['sync', '--revision', '[email protected]%s' % self.post_merge_sha])
self.CheckStatusPostMergePoint()
# Go backwards and check that we still have the foo branch.
self.gclient(['sync', '--revision', '[email protected]%s' % self.pre_merge_sha])
self.CheckStatusPreMergePoint()
subprocess2.check_call(
['git', 'show-ref', '-q', '--verify', 'refs/heads/foo'], cwd=self.blink)
开发者ID:withtone,项目名称:depot_tools,代码行数:29,代码来源:gclient_smoketest.py
示例9: main
def main():
tool_dir = os.path.dirname(os.path.abspath(__file__))
parser = optparse.OptionParser(usage="<new webkit rev>")
parser.add_option("-v", "--verbose", action="count", default=0)
options, args = parser.parse_args()
logging.basicConfig(level=[logging.WARNING, logging.INFO, logging.DEBUG][min(2, options.verbose)])
if len(args) != 1:
parser.error("Need only one arg: new webkit revision to roll to.")
root_dir = os.path.dirname(tool_dir)
os.chdir(root_dir)
new_rev = int(args[0])
print "Roll webkit revision to %s" % new_rev
# Silence the editor.
os.environ["EDITOR"] = "true"
old_branch = scm.GIT.GetBranch(root_dir)
if old_branch == "webkit_roll":
parser.error("Please delete the branch webkit_roll and move to a different branch")
subprocess2.check_output(["git", "checkout", "-b", "webkit_roll", "origin/master"])
try:
old_rev = process_deps(os.path.join(root_dir, "DEPS"), new_rev)
commit_msg = "Webkit roll %s:%s\n\nTBR=\n" % (old_rev, new_rev)
subprocess2.check_output(["git", "commit", "-m", commit_msg, "DEPS"])
subprocess2.check_call(["git", "diff", "origin/master"])
subprocess2.check_call(["git", "cl", "upload", "--use-commit-queue"])
finally:
subprocess2.check_output(["git", "checkout", old_branch])
subprocess2.check_output(["git", "branch", "-D", "webkit_roll"])
return 0
开发者ID:tristan-lin,项目名称:WProf,代码行数:32,代码来源:safely-roll-webkit.py
示例10: main
def main():
tool_dir = os.path.dirname(os.path.abspath(__file__))
parser = optparse.OptionParser(usage='<new webkit rev>')
parser.add_option('-v', '--verbose', action='count', default=0)
parser.add_option('--commit', action='store_true', default=True,
help='(default) Put change in commit queue on upload.')
parser.add_option('--no-commit', action='store_false', dest='commit',
help='Don\'t put change in commit queue on upload.')
parser.add_option('-r', '--reviewers', default='',
help='Add given users as either reviewers or TBR as'
' appropriate.')
parser.add_option('--upstream', default='origin/master',
help='(default "%default") Use given start point for change'
' to upload. For instance, if you use the old git workflow,'
' you might set it to "origin/trunk".')
parser.add_option('--cc', help='CC email addresses for issue.')
options, args = parser.parse_args()
logging.basicConfig(
level=
[logging.WARNING, logging.INFO, logging.DEBUG][
min(2, options.verbose)])
if len(args) != 1:
parser.error('Need only one arg: new webkit revision to roll to.')
root_dir = os.path.dirname(tool_dir)
os.chdir(root_dir)
new_rev = int(args[0])
print 'Roll webkit revision to %s' % new_rev
# Silence the editor.
os.environ['EDITOR'] = 'true'
old_branch = scm.GIT.GetBranch(root_dir)
if old_branch == 'webkit_roll':
parser.error(
'Please delete the branch webkit_roll and move to a different branch')
subprocess2.check_output(
['git', 'checkout', '-b', 'webkit_roll', options.upstream])
try:
old_rev = process_deps(os.path.join(root_dir, 'DEPS'), new_rev)
review_field = 'TBR' if options.commit else 'R'
commit_msg = 'Webkit roll %s:%s\n\n%s=%s\n' % (old_rev, new_rev,
review_field,
options.reviewers)
subprocess2.check_output(['git', 'commit', '-m', commit_msg, 'DEPS'])
subprocess2.check_call(['git', 'diff', options.upstream])
upload_cmd = ['git', 'cl', 'upload']
if options.commit:
upload_cmd.append('--use-commit-queue')
if options.reviewers:
upload_cmd.append('--send-mail')
if options.cc:
upload_cmd.extend(['--cc', options.cc])
subprocess2.check_call(upload_cmd)
finally:
subprocess2.check_output(['git', 'checkout', old_branch])
subprocess2.check_output(['git', 'branch', '-D', 'webkit_roll'])
return 0
开发者ID:gotomypc,项目名称:Readium-Chromium,代码行数:60,代码来源:safely-roll-webkit.py
示例11: RunEditor
def RunEditor(content, git, git_editor=None):
"""Opens up the default editor in the system to get the CL description."""
file_handle, filename = tempfile.mkstemp(text=True, prefix='cl_description')
# Make sure CRLF is handled properly by requiring none.
if '\r' in content:
print >> sys.stderr, (
'!! Please remove \\r from your change description !!')
fileobj = os.fdopen(file_handle, 'w')
# Still remove \r if present.
content = re.sub('\r?\n', '\n', content)
# Some editors complain when the file doesn't end in \n.
if not content.endswith('\n'):
content += '\n'
fileobj.write(content)
fileobj.close()
try:
editor = GetEditor(git, git_editor=git_editor)
if not editor:
return None
cmd = '%s %s' % (editor, filename)
if sys.platform == 'win32' and os.environ.get('TERM') == 'msys':
# Msysgit requires the usage of 'env' to be present.
cmd = 'env ' + cmd
try:
# shell=True to allow the shell to handle all forms of quotes in
# $EDITOR.
subprocess2.check_call(cmd, shell=True)
except subprocess2.CalledProcessError:
return None
return FileRead(filename)
finally:
os.remove(filename)
开发者ID:daykin,项目名称:chromium_27,代码行数:33,代码来源:gclient_utils.py
示例12: populateSvn
def populateSvn(self):
"""Create revisions which simulate the Skia DEPS transition in Chrome."""
subprocess2.check_call(
['svn', 'checkout', self.svn_base, self.svn_checkout,
'-q', '--non-interactive', '--no-auth-cache',
'--username', self.USERS[0][0], '--password', self.USERS[0][1]])
assert os.path.isdir(join(self.svn_checkout, '.svn'))
# Skia repo.
self._commit_svn({
'skia/skia_base_file': 'root-level file.',
'skia/gyp/gyp_file': 'file in the gyp directory',
'skia/include/include_file': 'file in the include directory',
'skia/src/src_file': 'file in the src directory',
})
# Chrome repo.
self._commit_svn({
'trunk/src/DEPS': self.DEPS_svn_pre % {'svn_base': self.svn_base},
'trunk/src/myfile': 'svn/trunk/[email protected]'
})
self._commit_svn({
'trunk/src/DEPS': self.DEPS_post % {'git_base': self.git_base},
'trunk/src/myfile': 'svn/trunk/[email protected]'
})
开发者ID:nakdai,项目名称:izanagi,代码行数:25,代码来源:fake_repos.py
示例13: RunEditor
def RunEditor(content, git, git_editor=None):
"""Opens up the default editor in the system to get the CL description."""
file_handle, filename = tempfile.mkstemp(text=True)
# Make sure CRLF is handled properly by requiring none.
if "\r" in content:
print >> sys.stderr, ("!! Please remove \\r from your change description !!")
fileobj = os.fdopen(file_handle, "w")
# Still remove \r if present.
fileobj.write(re.sub("\r?\n", "\n", content))
fileobj.close()
try:
editor = GetEditor(git, git_editor=git_editor)
if not editor:
return None
cmd = "%s %s" % (editor, filename)
if sys.platform == "win32" and os.environ.get("TERM") == "msys":
# Msysgit requires the usage of 'env' to be present.
cmd = "env " + cmd
try:
# shell=True to allow the shell to handle all forms of quotes in
# $EDITOR.
subprocess2.check_call(cmd, shell=True)
except subprocess2.CalledProcessError:
return None
return FileRead(filename)
finally:
os.remove(filename)
开发者ID:Nitrillo,项目名称:webrtc-android,代码行数:28,代码来源:gclient_utils.py
示例14: get_dllexports
def get_dllexports(dll):
""" Get exports of DLL. """
dll2def = os.path.join(env.bin_dir, 'dll2def.exe')
if not os.path.isfile(dll2def):
build_script = os.path.join(env.src_dir, 'dll2def', 'build.bat')
try:
subproc.check_call([ build_script ], stderr=subproc.VOID, stdout=subproc.VOID, stdin=subproc.VOID)
except subproc.CalledProcessError:
import traceback
traceback.print_exc()
fatal_message(
'Failed to build dll2def',
''.join((
'There was an error while trying to build dll2def. To resolve this issue, you ',
'may want to check the following files to make sure they are correct:\n\n',
' /repository/util/src/dll2def/build.bat\n'
' /repository/util/bin/msvcc.bat\n'
' /repository/util/bin/_buildenv.bat\n\n'
'If you continue having issue, please report this error at this project\'s GitHub. ',
'(https://github.com/Juntalis/dypywin32)'
))
)
return split_lines_clean(subproc.check_output(
[ dll2def, env.data_file(dll) ], stderr=subproc.VOID
))
开发者ID:juntalis,项目名称:dypywin32,代码行数:25,代码来源:gendecls.py
示例15: install_prerequisites
def install_prerequisites(self):
# First, install the Google AppEngine SDK.
cmd = [os.path.join(self.base_dir, 'get_appengine.py'),
'--dest=%s' % self.base_dir]
try:
subprocess2.check_call(cmd)
except (OSError, subprocess2.CalledProcessError), e:
raise Failure('Failed to run %s\n%s' % (cmd, e))
开发者ID:Cyril2004,项目名称:proto-quic,代码行数:8,代码来源:local_rietveld.py
示例16: system3
def system3(*parms, **kwargs):
print subprocess.list2cmdline(parms)
try:
subprocess.check_call(parms, **kwargs)
except (OSError, subprocess.CalledProcessError), err:
print "execution failure, aborting:", parms
print err
sys.exit(2)
开发者ID:rbianchi66,项目名称:pyqt_md,代码行数:8,代码来源:common.py
示例17: test_check_call_throw
def test_check_call_throw(self):
try:
subprocess2.check_call(self.exe + ['--fail', '--stderr'])
self.fail()
except subprocess2.CalledProcessError, e:
self.assertEquals(None, e.stdout)
self.assertEquals(None, e.stderr)
self.assertEquals(64, e.returncode)
开发者ID:lexuanquyen,项目名称:chromium_base,代码行数:8,代码来源:subprocess2_test.py
示例18: commit_git
def commit_git(repo):
"""Commits the changes and returns the new hash."""
subprocess2.check_call(['git', 'add', '-A', '-f'], cwd=repo)
subprocess2.check_call(['git', 'commit', '-q', '--message', 'foo'], cwd=repo)
rev = subprocess2.check_output(
['git', 'show-ref', '--head', 'HEAD'], cwd=repo).split(' ', 1)[0]
logging.debug('At revision %s' % rev)
return rev
开发者ID:jgrowl,项目名称:depot_tools,代码行数:8,代码来源:fake_repos.py
示例19: CMDrebase
def CMDrebase(parser, args):
"""rebase current branch on top of svn repo"""
# Provide a wrapper for git svn rebase to help avoid accidental
# git svn dcommit.
# It's the only command that doesn't use parser at all since we just defer
# execution to git-svn.
subprocess2.check_call(['git', 'svn', 'rebase'] + args)
return 0
开发者ID:lexuanquyen,项目名称:chromium_base,代码行数:8,代码来源:git_cl.py
示例20: populateSvn
def populateSvn(self):
"""Creates a few revisions of changes files."""
subprocess2.check_call(
['svn', 'checkout', self.svn_base, self.svn_checkout, '-q',
'--non-interactive', '--no-auth-cache',
'--username', self.USERS[0][0], '--password', self.USERS[0][1]])
assert os.path.isdir(os.path.join(self.svn_checkout, '.svn'))
self._commit_svn(self._tree_1())
self._commit_svn(self._tree_2())
开发者ID:Nitrillo,项目名称:webrtc-android,代码行数:9,代码来源:checkout_test.py
注:本文中的subprocess2.check_call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论