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

Python sh.echo函数代码示例

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

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



在下文中一共展示了echo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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')
开发者ID:jonesetc,项目名称:grader-scripts,代码行数:7,代码来源:__init__.py


示例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)
开发者ID:themalkolm,项目名称:git-boots,代码行数:29,代码来源:test_fix.py


示例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())
开发者ID:imZack,项目名称:sanji-bundle-cellular,代码行数:8,代码来源:test_cellular.py


示例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"])
开发者ID:Swind,项目名称:clif,代码行数:10,代码来源:echo_hello_world.py


示例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)
开发者ID:themalkolm,项目名称:git-boots,代码行数:11,代码来源:test_fix.py


示例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
开发者ID:dmascialino,项目名称:waliki,代码行数:7,代码来源:moin_migration_cleanup.py


示例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)
开发者ID:dschexna,项目名称:fedemo,代码行数:7,代码来源:test.py


示例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)
开发者ID:naftaliharris,项目名称:markovian,代码行数:16,代码来源:runtests.py


示例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)
开发者ID:mess110,项目名称:servusberry,代码行数:16,代码来源:command_builder.py


示例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")
开发者ID:ahhentz,项目名称:sh,代码行数:16,代码来源:test.py


示例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)
开发者ID:ahhentz,项目名称:sh,代码行数:8,代码来源:test.py


示例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)
开发者ID:Aeva,项目名称:voice,代码行数:8,代码来源:festival.py


示例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()
开发者ID:isnok,项目名称:pylo,代码行数:10,代码来源:Helpers.py


示例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",
    )
开发者ID:shunyata,项目名称:web-avatar,代码行数:10,代码来源:festival.py


示例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)
开发者ID:0xr0ot,项目名称:sh,代码行数:10,代码来源:test.py


示例16: create_loop

    def create_loop(self, loop, path, size):
        """Create a new loopback device."""
        is_in = self.find_loop(loop)
        if is_in:
            raise Exception("loop device already installed: %s / %s" % is_in)

        self.ssh.dd("if=/dev/zero", "of=%s" % path, "bs=1M", "count=%d" % size)
        self.ssh.fdisk(sh.echo("-e", r"o\nn\np\n1\n\n\nw"), path)
        self.ssh.losetup(loop, path)

        is_in = self.find_loop(loop)
        if not is_in:
            raise Exception("fail to create loop device: %s / %s" % is_in)
开发者ID:vwallfahrer,项目名称:automation,代码行数:13,代码来源:iscsictl.py


示例17: create_base

def create_base(folder):
    """
    Create multisite Plone hosting infrastructure on a server..

    Host sites at /srv/plone or chosen cache_folder

    Each folder has a file called buildout.cfg which is the production buildout file
    for this site. This might not be a real file, but a symlink to a version controlled
    file under /srv/plone/xxx/src/yoursitecustomization.policy/production.cfg.

    Log rotate is performed using a global UNIX log rotate script:
    http://opensourcehacker.com/2012/08/30/autodiscovering-log-files-for-logrotate/

    :param folder: Base installation folder for all the sites e.g. /srv/plone
    """
    from sh import apt_get

    with sudo:

        # Return software we are going to need in any case
        # Assumes Ubuntu / Debian
        # More info: https://github.com/miohtama/ztanesh
        if (not which("zsh")) or (not which("git")) or (not which("gcc")):
            # Which returs zero on success
            print "Installing OS packages"
            apt_get("update")
            apt_get("install", "-y", *PACKAGES)

        # Create base folder
        if not os.path.exists(folder):
            print "Creating installation base %s" % folder
            install(folder, "-d")

        # Create nightly restart cron job
        if os.path.exists("/etc/cron.d"):
            print "(Re)setting all sites nightly restart cron job"
            echo(CRON_TEMPLATE, _out=CRON_JOB)

    create_python_env(folder)
开发者ID:miohtama,项目名称:senorita.plonetool,代码行数:39,代码来源:main.py


示例18: create_python_env

def create_python_env(folder):
    """
    Compile a Python environment with various Python versions to run Plone.

    Create Python's under /srv/plone/python

    Use https://github.com/collective/buildout.python
    """
    from sh import git

    python_target = os.path.join(folder, "python")

    print "Setting up various Python versions at %s" % python_target

    with sudo:

        if not os.path.exists(python_target):
            cd(folder)
            git("clone", "git://github.com/collective/buildout.python.git", "python")

        if not os.path.exists(os.path.join(python_target, "python-2.7", "bin", "python")):
            cd(python_target)
            echo(PYTHON_BUILDOUT, _out="%s/buildout.cfg" % python_target)
            python("bootstrap.py")
            run = Command("%s/bin/buildout" % python_target)
            run()

        pip = Command("%s/python-2.7/bin/pip" % python_target)

        # Avoid buildout bootstrap global python write bug using Distribute 0.6.27
        pip("install", "--upgrade", "Distribute")

        # Plone 4.x sites heavily rely on lxml
        # Create a shared lxml installation. System deps should have been installed before.
        # for plone 3.x do this by hand
        # collective.buildout.python does not do lxml, which is crucial
        pip("install", "lxml")
开发者ID:miohtama,项目名称:senorita.plonetool,代码行数:37,代码来源:main.py


示例19: create_site_initd_script

def create_site_initd_script(name, folder, username):
    """
    Install /etc/init.d boot script for a Plone site.

    We do this Ubuntu style, not sure if works 100% on Debian.

    http://wiki.debian.org/LSBInitScripts

    http://developer.plone.org/hosting/restarts.html#lsbinitscripts-starting-with-debian-6-0
    """

    from sh import chmod

    updaterc = Command("/usr/sbin/update-rc.d")

    script_body = DEBIAN_BOOT_TEMPLATE % dict(user=username, folder=folder, name=name)

    initd_script = "/etc/init.d/%s" % name

    print "Creating start/stop script %s" % initd_script
    with sudo:
        echo(script_body, _out=initd_script)
        chmod("u+x", initd_script)
        updaterc(name, "defaults")
开发者ID:miohtama,项目名称:senorita.plonetool,代码行数:24,代码来源:main.py


示例20: set_hostname

    def set_hostname(self, hostname):
        """Update hostname

            Args:
                hostname (str): hostname to be updated
        """
        try:
            old_hostname = self.get_hostname()

            is_valid_hostname(hostname)

            sh.hostname("-b", hostname)
            sh.echo(hostname, _out="/etc/hostname")

            try:
                # sed -i 's/ old$/ new/g' /etc/hosts
                sh.sed("-i", "s/ {}$/ {}/g".format(old_hostname, hostname),
                       "/etc/hosts")
            except:
                with open("/etc/hosts", "a") as f:
                    f.write("127.0.0.1       localhost {}\n".format(hostname))
            self.update(id=1, newObj={"hostname": hostname})
        except Exception as e:
            raise e
开发者ID:Sanji-IO,项目名称:sanji-bundle-status,代码行数:24,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python sh.git函数代码示例发布时间:2022-05-27
下一篇:
Python sh.curl函数代码示例发布时间: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