本文整理汇总了Python中sh.echo函数的典型用法代码示例。如果您正苦于以下问题:Python echo函数的具体用法?Python echo怎么用?Python echo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了echo函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
def test():
if not os.path.isfile('a.out'):
sh.echo('No executable found', _out='results.txt')
return
result = sh.Command('./a.out')
result(_out='results.txt')
示例2: test_should_not_pop_stash_on_failure
def test_should_not_pop_stash_on_failure(self):
from sh import echo
git_touch_add_commit('foo', 'bar', 'moo')
foo_commit, _ = git_log_oneline()[2]
echo('bar', _out='bar')
echo('moo', _out='moo')
git('add', 'bar')
expected = {
'bar': 'M ',
'moo': ' M'
}
self.assertEqual(expected, git_status())
with self.assertRaises(GitRebaseFailed):
fix(foo_commit)
status = {
'bar': 'DU'
}
self.assertEqual(status, git_status())
self.assertEqual(1, git_stash_len())
actual = git_show('HEAD')['subject']
expected = git_show(foo_commit)['subject']
self.assertEqual(expected, actual)
示例3: setUp
def setUp(self, set_pincode_by_id):
sh.echo("1234, 1234", _out="/run/shm/cellular.tmp")
try:
os.unlink(dirpath + "/../data/cellular.json")
except Exception:
pass
set_pincode_by_id.return_value = True
self.cellular = Cellular(connection=Mockup())
示例4: echo_hello_world_cmd
def echo_hello_world_cmd(**kwargs):
"""
Usage:
echo hello world --user <user> <target> [--chinese (yes|no)]
Options:
--user <user> Hello World [default: root]
-c,--chinese Use Chinese to say hello world
"""
print echo("echo hello world:" + kwargs["user"])
示例5: test_should_rollback_on_failure_if_requested
def test_should_rollback_on_failure_if_requested(self):
from sh import echo
git_touch_add_commit('foo', 'bar')
foo_commit, _ = git_log_oneline()[1]
echo('bar', _out='bar')
git('add', 'bar')
with self.assertRaises(GitRebaseFailed):
with git_state_invariant():
fix('--atomic', foo_commit)
示例6: convert
def convert(match):
source = match.groups()[0]
source = '\n'.join(l.strip() for l in source.split('\n'))
source = "<pre>%s</pre>" % source
rst_source = pandoc(echo(source), f='html', t='rst').stdout.decode('utf8')
# rst_source = rst_source.strip().replace('\n', '\n ') + '\n'
return rst_source
示例7: test_unicode_arg
def test_unicode_arg(self):
from sh import echo
if IS_PY3: test = "漢字"
else: test = "漢字".decode("utf8")
p = echo(test).strip()
self.assertEqual(test, p)
示例8: test_search
def test_search(self):
"""Make sure aspiration search is the same as ordinary search
Uses random fens as values, so not guaranteed to produce the same
output when run multiple times"""
lines = str(sh.rl("test/data/fenio.fens", "--count=10")).rstrip("\n")
sh.make("aspire_search")
run = sh.Command("./aspire_search")
aspire_output = str(run(sh.echo(lines)))
sh.make("no_aspire_search")
run = sh.Command("./no_aspire_search")
no_aspire_output = str(run(sh.echo(lines)))
for fen_orig, fen1, fen2 in zip(lines.split("\n"), aspire_output.split("\n"), no_aspire_output.split("\n")):
self.assertEquals(fen1, fen2, "Original fen: '%s'" % fen_orig)
示例9: avi_seek
def avi_seek(seek):
fifo = '/tmp/omxplayer_fifo'
direction = ''
if seek == 1:
direction = "$'\x1b\x5b\x42'"
elif seek == 2:
direction = "$'\x1b\x5b\x44'"
elif seek == 3:
direction = "$'\x1b\x5b\x43'"
elif seek == 4:
direction = "$'\x1b\x5b\x41'"
else:
direction = "."
sh.echo('-n', direction, '>', fifo, _bg=True)
示例10: test_stringio_output
def test_stringio_output(self):
from sh import echo
if IS_PY3:
from io import StringIO
from io import BytesIO as cStringIO
else:
from StringIO import StringIO
from cStringIO import StringIO as cStringIO
out = StringIO()
echo("-n", "testing 123", _out=out)
self.assertEqual(out.getvalue(), "testing 123")
out = cStringIO()
echo("-n", "testing 123", _out=out)
self.assertEqual(out.getvalue().decode(), "testing 123")
示例11: test_unicode_arg
def test_unicode_arg(self):
from sh import echo
test = "漢字"
if not IS_PY3: test = test.decode("utf8")
p = echo(test).strip()
self.assertEqual(test, p)
示例12: say
def say(self, message, voice=None, block=True):
if not voice:
voice = self.default_voice
voice_part = '(voice_{0})'.format(voice)
text_part = '(SayText "{0}")'.format(common.sterilize(message))
command = voice_part + text_part
festival(echo(command), _bg=not block)
示例13: run_jbofihe
def run_jbofihe(args, lojban):
""" In order to pipe correctly we have to use two commandline wrappers. """
try:
return sh.jbofihe(sh.echo(lojban), *args.split())
except Exception, e:
print "Got an error: %s" % type(e)
print "It reads:"
print e.message
print "The Exception vanishes in a puff of lojic."
sys.exit()
示例14: say_sync
def say_sync(text):
to_say = echo(text)
audio = festival_client(to_say, ttw=True)
paplay( audio,
channels=1,
raw=True,
format="s16le",
rate=32000,
device="teesink",
)
示例15: test_unicode_arg
def test_unicode_arg(self):
from sh import echo
test = "漢字"
if not IS_PY3:
test = test.decode("utf8")
p = echo(test, _encoding="utf8")
output = p.strip()
self.assertEqual(test, output)