當前位置: 首頁>>代碼示例>>Python>>正文


Python Context.cd方法代碼示例

本文整理匯總了Python中invoke.Context.cd方法的典型用法代碼示例。如果您正苦於以下問題:Python Context.cd方法的具體用法?Python Context.cd怎麽用?Python Context.cd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在invoke.Context的用法示例。


在下文中一共展示了Context.cd方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cd_should_apply_to_sudo

# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import cd [as 別名]
        def cd_should_apply_to_sudo(self, Local):
            runner = Local.return_value
            c = Context()
            with c.cd("foo"):
                c.sudo("whoami")

            cmd = "sudo -S -p '[sudo] password: ' cd foo && whoami"
            assert runner.run.called, "sudo() never called runner.run()!"
            assert runner.run.call_args[0][0] == cmd
開發者ID:miradam,項目名稱:invoke,代碼行數:11,代碼來源:context.py

示例2: cd_should_apply_to_sudo

# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import cd [as 別名]
        def cd_should_apply_to_sudo(self, Local):
            runner = Local.return_value
            ctx = Context()
            with ctx.cd('foo'):
                ctx.sudo('whoami')

            cmd = "sudo -S -p '[sudo] password: ' cd foo && whoami"
            ok_(runner.run.called, "sudo() never called runner.run()!")
            eq_(runner.run.call_args[0][0], cmd)
開發者ID:yws,項目名稱:invoke,代碼行數:11,代碼來源:context.py

示例3: cd_should_apply_to_run

# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import cd [as 別名]
        def cd_should_apply_to_run(self, Local):
            runner = Local.return_value
            c = Context()
            with c.cd("foo"):
                c.run("whoami")

            cmd = "cd foo && whoami"
            assert runner.run.called, "run() never called runner.run()!"
            assert runner.run.call_args[0][0] == cmd
開發者ID:miradam,項目名稱:invoke,代碼行數:11,代碼來源:context.py

示例4: cd_should_apply_to_run

# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import cd [as 別名]
        def cd_should_apply_to_run(self, Local):
            runner = Local.return_value
            ctx = Context()
            with ctx.cd('foo'):
                ctx.run('whoami')

            cmd = "cd foo && whoami"
            ok_(runner.run.called, "run() never called runner.run()!")
            eq_(runner.run.call_args[0][0], cmd)
開發者ID:yws,項目名稱:invoke,代碼行數:11,代碼來源:context.py

示例5: cd_should_occur_before_prefixes

# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import cd [as 別名]
        def cd_should_occur_before_prefixes(self, Local):
            runner = Local.return_value
            c = Context()
            with c.prefix("source venv"):
                with c.cd("foo"):
                    c.run("whoami")

            cmd = "cd foo && source venv && whoami"
            assert runner.run.called, "run() never called runner.run()!"
            assert runner.run.call_args[0][0] == cmd
開發者ID:miradam,項目名稱:invoke,代碼行數:12,代碼來源:context.py

示例6: cd_should_occur_before_prefixes

# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import cd [as 別名]
        def cd_should_occur_before_prefixes(self, Local):
            runner = Local.return_value
            ctx = Context()
            with ctx.prefix('source venv'):
                with ctx.cd('foo'):
                    ctx.run('whoami')

            cmd = "cd foo && source venv && whoami"
            ok_(runner.run.called, "run() never called runner.run()!")
            eq_(runner.run.call_args[0][0], cmd)
開發者ID:yws,項目名稱:invoke,代碼行數:12,代碼來源:context.py

示例7: build

# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import cd [as 別名]
    def build(self, ctx: Context) -> None:
        if self.platform in [SupportedPlatformEnum.WINDOWS_32, SupportedPlatformEnum.WINDOWS_64]:
            if self.platform == SupportedPlatformEnum.WINDOWS_32:
                arch = 'x86'
                build_script = 'bld_ml32.bat'
                build_platform = 'Win32'
            else:
                arch = 'x64'
                build_script = 'bld_ml64.bat'
                build_platform = 'x64'

            masm_path = self.src_path / 'contrib' / f'masm{arch}'
            with ctx.cd(str(masm_path)):
                ctx.run(build_script)
                ctx.run(f'msbuild ..\\vstudio\\vc14\\zlibvc.sln /P:Configuration=Release /P:Platform={build_platform}')

        else:
            # Linux/macOS build
            with ctx.cd(str(self.src_path)):
                ctx.run('CFLAGS="-fPIC" ./configure -static')
                ctx.run('make clean')
                ctx.run('make')
開發者ID:nabla-c0d3,項目名稱:nassl,代碼行數:24,代碼來源:build_tasks.py

示例8: _build

# 需要導入模塊: from invoke import Context [as 別名]
# 或者: from invoke.Context import cd [as 別名]
def _build():
    """
    Build local support docs tree and return the build target dir for cleanup.
    """
    c = Context()
    support = join(dirname(__file__), "_support")
    docs = join(support, "docs")
    build = join(support, "_build")
    command = "sphinx-build -c {} -W {} {}".format(support, docs, build)
    with c.cd(support):
        # Turn off stdin mirroring to avoid irritating pytest.
        c.run(command, in_stream=False)
    return build
開發者ID:pyinvoke,項目名稱:invocations,代碼行數:15,代碼來源:base.py


注:本文中的invoke.Context.cd方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。