本文整理汇总了Python中webkitpy.common.system.executive.Executive.run_command方法的典型用法代码示例。如果您正苦于以下问题:Python Executive.run_command方法的具体用法?Python Executive.run_command怎么用?Python Executive.run_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webkitpy.common.system.executive.Executive
的用法示例。
在下文中一共展示了Executive.run_command方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run_command_with_unicode
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def test_run_command_with_unicode(self):
"""Validate that it is safe to pass unicode() objects
to Executive.run* methods, and they will return unicode()
objects by default unless decode_output=False"""
unicode_tor_input = u"WebKit \u2661 Tor Arne Vestb\u00F8!"
if sys.platform == 'win32':
encoding = 'mbcs'
else:
encoding = 'utf-8'
encoded_tor = unicode_tor_input.encode(encoding)
# On Windows, we expect the unicode->mbcs->unicode roundtrip to be
# lossy. On other platforms, we expect a lossless roundtrip.
if sys.platform == 'win32':
unicode_tor_output = encoded_tor.decode(encoding)
else:
unicode_tor_output = unicode_tor_input
executive = Executive()
output = executive.run_command(command_line('cat'), input=unicode_tor_input)
self.assertEqual(output, unicode_tor_output)
output = executive.run_command(command_line('echo', unicode_tor_input))
self.assertEqual(output, unicode_tor_output)
output = executive.run_command(command_line('echo', unicode_tor_input), decode_output=False)
self.assertEqual(output, encoded_tor)
# Make sure that str() input also works.
output = executive.run_command(command_line('cat'), input=encoded_tor, decode_output=False)
self.assertEqual(output, encoded_tor)
示例2: test_run_command_with_unicode
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def test_run_command_with_unicode(self):
"""Validate that it is safe to pass unicode() objects
to Executive.run* methods, and they will return unicode()
objects by default unless decode_output=False"""
executive = Executive()
unicode_tor = u"WebKit \u2661 Tor Arne Vestb\u00F8!"
utf8_tor = unicode_tor.encode("utf-8")
output = executive.run_command(["cat"], input=unicode_tor)
self.assertEquals(output, unicode_tor)
output = executive.run_command(["echo", "-n", unicode_tor])
self.assertEquals(output, unicode_tor)
output = executive.run_command(["echo", "-n", unicode_tor], decode_output=False)
self.assertEquals(output, utf8_tor)
# Make sure that str() input also works.
output = executive.run_command(["cat"], input=utf8_tor, decode_output=False)
self.assertEquals(output, utf8_tor)
# FIXME: We should only have one run* method to test
output = executive.run_and_throw_if_fail(["echo", "-n", unicode_tor], quiet=True)
self.assertEquals(output, unicode_tor)
output = executive.run_and_throw_if_fail(["echo", "-n", unicode_tor], quiet=True, decode_output=False)
self.assertEquals(output, utf8_tor)
示例3: _run_pylint
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def _run_pylint(self, path):
wkf = WebKitFinder(FileSystem())
executive = Executive()
return executive.run_command([sys.executable, wkf.path_from_depot_tools_base('pylint.py'),
'--output-format=parseable',
'--errors-only',
'--rcfile=' + wkf.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'pylintrc'),
path],
error_handler=executive.ignore_error)
示例4: integration_test_run_wdiff
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def integration_test_run_wdiff(self):
executive = Executive()
# This may fail on some systems. We could ask the port
# object for the wdiff path, but since we don't know what
# port object to use, this is sufficient for now.
try:
wdiff_path = executive.run_command(["which", "wdiff"]).rstrip()
except Exception, e:
wdiff_path = None
示例5: _run_pylint
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def _run_pylint(self, path):
wkf = WebKitFinder(FileSystem())
executive = Executive()
env = os.environ.copy()
env['PYTHONPATH'] = ('%s%s%s' % (wkf.path_from_webkit_base('Tools', 'Scripts'),
os.pathsep,
wkf.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'thirdparty')))
return executive.run_command([sys.executable, wkf.path_from_depot_tools_base('pylint.py'),
'--output-format=parseable',
'--errors-only',
'--rcfile=' + wkf.path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'pylintrc'),
path],
env=env,
error_handler=executive.ignore_error)
示例6: test_default_configuration__standalone
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def test_default_configuration__standalone(self):
# FIXME: This test runs a standalone python script to test
# reading the default configuration to work around any possible
# caching / reset bugs. See https://bugs.webkit.org/show_bug.cgi?id=49360
# for the motivation. We can remove this test when we remove the
# global configuration cache in config.py.
e = Executive()
fs = FileSystem()
c = config.Config(e, fs)
script = WebKitFinder(fs).path_from_webkit_base('Tools', 'Scripts', 'webkitpy', 'layout_tests', 'port', 'config_standalone.py')
# Note: don't use 'Release' here, since that's the normal default.
expected = 'Debug'
args = [sys.executable, script, '--mock', expected]
actual = e.run_command(args).rstrip()
self.assertEqual(actual, expected)
示例7: test_default_configuration__standalone
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def test_default_configuration__standalone(self):
# FIXME: This test runs a standalone python script to test
# reading the default configuration to work around any possible
# caching / reset bugs. See https://bugs.webkit.org/show_bug.cgi?id=49360
# for the motivation. We can remove this test when we remove the
# global configuration cache in config.py.
e = Executive()
fs = FileSystem()
c = config.Config(e, fs)
script = c.path_from_webkit_base("Tools", "Scripts", "webkitpy", "layout_tests", "port", "config_standalone.py")
# Note: don't use 'Release' here, since that's the normal default.
expected = "Debug"
# FIXME: Why are we running a python subprocess here??
args = [sys.executable, script, "--mock", expected]
actual = e.run_command(args).rstrip()
self.assertEqual(actual, expected)
示例8: diff_diff
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def diff_diff(cls, diff1, diff2, diff1_suffix, diff2_suffix, executive=None):
# Now this is where it gets complicated, we need to compare our diff to the diff at landed_revision.
diff1_patch = tempfile.NamedTemporaryFile(suffix=diff1_suffix + '.patch')
diff1_patch.write(diff1)
diff1_patch.flush()
# Check if there are any differences in the patch that don't happen
diff2_patch = tempfile.NamedTemporaryFile(suffix=diff2_suffix + '.patch')
diff2_patch.write(diff2)
diff2_patch.flush()
# Diff the two diff's together...
if not executive:
executive = Executive()
try:
return executive.run_command(
["interdiff", diff1_patch.name, diff2_patch.name], decode_output=False)
except ScriptError, e:
_log.warning("Unable to find interdiff util (part of GNU difftools package) which is required.")
raise
示例9: test_auto_stringify_args
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def test_auto_stringify_args(self):
executive = Executive()
executive.run_command(command_line('echo', 1))
executive.popen(command_line('echo', 1), stdout=executive.PIPE).wait()
self.assertEqual('echo 1', executive.command_for_printing(['echo', 1]))
示例10: SCMTestBase
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
class SCMTestBase(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(SCMTestBase, self).__init__(*args, **kwargs)
self.scm = None
self.executive = None
self.fs = None
self.original_cwd = None
def setUp(self):
self.executive = Executive()
self.fs = FileSystem()
self.original_cwd = self.fs.getcwd()
def tearDown(self):
self._chdir(self.original_cwd)
def _join(self, *comps):
return self.fs.join(*comps)
def _chdir(self, path):
self.fs.chdir(path)
def _mkdir(self, path):
assert not self.fs.exists(path)
self.fs.maybe_make_directory(path)
def _mkdtemp(self, **kwargs):
return str(self.fs.mkdtemp(**kwargs))
def _remove(self, path):
self.fs.remove(path)
def _rmtree(self, path):
self.fs.rmtree(path)
def _run(self, *args, **kwargs):
return self.executive.run_command(*args, **kwargs)
def _run_silent(self, args, **kwargs):
self.executive.run_and_throw_if_fail(args, quiet=True, **kwargs)
def _write_text_file(self, path, contents):
self.fs.write_text_file(path, contents)
def _write_binary_file(self, path, contents):
self.fs.write_binary_file(path, contents)
def _make_diff(self, command, *args):
# We use this wrapper to disable output decoding. diffs should be treated as
# binary files since they may include text files of multiple differnet encodings.
return self._run([command, "diff"] + list(args), decode_output=False)
def _svn_diff(self, *args):
return self._make_diff("svn", *args)
def _git_diff(self, *args):
return self._make_diff("git", *args)
def _svn_add(self, path):
self._run(["svn", "add", path])
def _svn_commit(self, message):
self._run(["svn", "commit", "--quiet", "--message", message])
# This is a hot function since it's invoked by unittest before calling each test_ method in SVNTest and
# GitTest. We create a mock SVN repo once and then perform an SVN checkout from a filesystem copy of
# it since it's expensive to create the mock repo.
def _set_up_svn_checkout(self):
global cached_svn_repo_path
global original_cwd
if not cached_svn_repo_path:
cached_svn_repo_path = self._set_up_svn_repo()
original_cwd = self.original_cwd
self.temp_directory = self._mkdtemp(suffix="svn_test")
self.svn_repo_path = self._join(self.temp_directory, "repo")
self.svn_repo_url = "file://%s" % self.svn_repo_path
self.svn_checkout_path = self._join(self.temp_directory, "checkout")
shutil.copytree(cached_svn_repo_path, self.svn_repo_path)
self._run(["svn", "checkout", "--quiet", self.svn_repo_url + "/trunk", self.svn_checkout_path])
def _set_up_svn_repo(self):
svn_repo_path = self._mkdtemp(suffix="svn_test_repo")
svn_repo_url = "file://%s" % svn_repo_path # Not sure this will work on windows
# git svn complains if we don't pass --pre-1.5-compatible, not sure why:
# Expected FS format '2'; found format '3' at /usr/local/libexec/git-core//git-svn line 1477
self._run(["svnadmin", "create", "--pre-1.5-compatible", svn_repo_path])
# Create a test svn checkout
svn_checkout_path = self._mkdtemp(suffix="svn_test_checkout")
self._run(["svn", "checkout", "--quiet", svn_repo_url, svn_checkout_path])
# Create and checkout a trunk dir to match the standard svn configuration to match git-svn's expectations
self._chdir(svn_checkout_path)
self._mkdir("trunk")
self._svn_add("trunk")
# We can add tags and branches as well if we ever need to test those.
self._svn_commit("add trunk")
self._rmtree(svn_checkout_path)
#.........这里部分代码省略.........
示例11: test_timeout_exceeded_exit_code
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def test_timeout_exceeded_exit_code(self):
executive = Executive()
exit_code = executive.run_command(command_line('sleep', 'infinity'), timeout_seconds=0.01, return_exit_code=True)
self.assertNotEqual(exit_code, 0)
示例12: check_ruby
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def check_ruby(self):
executive = Executive()
try:
result = executive.run_command(['ruby', '--version'])
except OSError, e:
return False
示例13: test_timeout_satisfied
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def test_timeout_satisfied(self):
executive = Executive()
executive.run_command(command_line('sleep', '0'), timeout_seconds=1000)
示例14: test_run_command_args_type
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
def test_run_command_args_type(self):
executive = Executive()
self.assertRaises(AssertionError, executive.run_command, "echo")
self.assertRaises(AssertionError, executive.run_command, u"echo")
executive.run_command(echo.command_arguments('foo'))
executive.run_command(tuple(echo.command_arguments('foo')))
示例15: SCMTestBase
# 需要导入模块: from webkitpy.common.system.executive import Executive [as 别名]
# 或者: from webkitpy.common.system.executive.Executive import run_command [as 别名]
class SCMTestBase(unittest.TestCase):
def __init__(self, *args, **kwargs):
super(SCMTestBase, self).__init__(*args, **kwargs)
self.scm = None
self.executive = None
self.fs = None
self.original_cwd = None
def setUp(self):
self.executive = Executive()
self.fs = FileSystem()
self.original_cwd = self.fs.getcwd()
def tearDown(self):
self._chdir(self.original_cwd)
def _join(self, *comps):
return self.fs.join(*comps)
def _chdir(self, path):
self.fs.chdir(path)
def _mkdir(self, path):
assert not self.fs.exists(path)
self.fs.maybe_make_directory(path)
def _mkdtemp(self, **kwargs):
return str(self.fs.mkdtemp(**kwargs))
def _remove(self, path):
self.fs.remove(path)
def _rmtree(self, path):
self.fs.rmtree(path)
def _run(self, *args, **kwargs):
return self.executive.run_command(*args, **kwargs)
def _run_silent(self, args, **kwargs):
self.executive.run_command(args, **kwargs)
def _write_text_file(self, path, contents):
self.fs.write_text_file(path, contents)
def _write_binary_file(self, path, contents):
self.fs.write_binary_file(path, contents)
def _make_diff(self, command, *args):
# We use this wrapper to disable output decoding. diffs should be treated as
# binary files since they may include text files of multiple differnet encodings.
return self._run([command, "diff"] + list(args), decode_output=False)
def _git_diff(self, *args):
return self._make_diff("git", *args)
def _shared_test_add_recursively(self):
self._mkdir("added_dir")
self._write_text_file("added_dir/added_file", "new stuff")
self.scm.add("added_dir/added_file")
self.assertIn("added_dir/added_file", self.scm._added_files())
def _shared_test_delete_recursively(self):
self._mkdir("added_dir")
self._write_text_file("added_dir/added_file", "new stuff")
self.scm.add("added_dir/added_file")
self.assertIn("added_dir/added_file", self.scm._added_files())
self.scm.delete("added_dir/added_file")
self.assertNotIn("added_dir", self.scm._added_files())
def _shared_test_delete_recursively_or_not(self):
self._mkdir("added_dir")
self._write_text_file("added_dir/added_file", "new stuff")
self._write_text_file("added_dir/another_added_file", "more new stuff")
self.scm.add("added_dir/added_file")
self.scm.add("added_dir/another_added_file")
self.assertIn("added_dir/added_file", self.scm._added_files())
self.assertIn("added_dir/another_added_file", self.scm._added_files())
self.scm.delete("added_dir/added_file")
self.assertIn("added_dir/another_added_file", self.scm._added_files())
def _shared_test_exists(self, scm, commit_function):
self._chdir(scm.checkout_root)
self.assertFalse(scm.exists('foo.txt'))
self._write_text_file('foo.txt', 'some stuff')
self.assertFalse(scm.exists('foo.txt'))
scm.add('foo.txt')
commit_function('adding foo')
self.assertTrue(scm.exists('foo.txt'))
scm.delete('foo.txt')
commit_function('deleting foo')
self.assertFalse(scm.exists('foo.txt'))
def _shared_test_move(self):
self._write_text_file('added_file', 'new stuff')
self.scm.add('added_file')
self.scm.move('added_file', 'moved_file')
self.assertIn('moved_file', self.scm._added_files())
def _shared_test_move_recursive(self):
#.........这里部分代码省略.........