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

Python command.AtomicCmd类代码示例

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

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



在下文中一共展示了AtomicCmd类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_atomiccmd__paths__key

def test_atomiccmd__paths__key(temp_folder):
    cmd = AtomicCmd(("echo", "-n", "%(TEMP_DIR)s"),
                    OUT_STDOUT=AtomicCmd.PIPE)
    cmd.run(temp_folder)
    path = cmd._proc.stdout.read()
    assert os.path.samefile(temp_folder, path), (temp_folder, path)
    assert_equal(cmd.join(), [0])
开发者ID:CarlesV,项目名称:paleomix,代码行数:7,代码来源:command_test.py


示例2: test_atomiccmd__commit_before_join

def test_atomiccmd__commit_before_join(temp_folder):
    cmd = AtomicCmd(("sleep", "0.1"))
    cmd.run(temp_folder)
    while cmd._proc.poll() is None:
        pass
    assert_raises(CmdError, cmd.commit, temp_folder)
    cmd.join()
开发者ID:CarlesV,项目名称:paleomix,代码行数:7,代码来源:command_test.py


示例3: test_atomiccmd__paths_non_str

def test_atomiccmd__paths_non_str(temp_folder):
    cmd = AtomicCmd(("touch", 1234),
                    OUT_FOO = "1234",
                    set_cwd = True)
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    assert os.path.exists(os.path.join(temp_folder, "1234"))
开发者ID:CarlesV,项目名称:paleomix,代码行数:7,代码来源:command_test.py


示例4: _do_test_atomiccmd__pipes_out

 def _do_test_atomiccmd__pipes_out(temp_folder, stdout, stderr, kwargs):
     cmd = AtomicCmd(("bash", "-c", "echo -n 'STDERR!' > /dev/stderr; echo -n 'STDOUT!';"), **kwargs)
     cmd.run(temp_folder)
     assert_equal(cmd.join(), [0])
     result_out = get_file_contents(os.path.join(temp_folder, stdout.format(id(cmd))))
     result_err = get_file_contents(os.path.join(temp_folder, stderr.format(id(cmd))))
     assert_equal(result_out, "STDOUT!")
     assert_equal(result_err, "STDERR!")
开发者ID:CarlesV,项目名称:paleomix,代码行数:8,代码来源:command_test.py


示例5: test_pformat__simple__done__set_cwd

def test_pformat__simple__done__set_cwd(temp_folder):
    cmd = AtomicCmd("true", set_cwd = True)
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    assert_equal(pformat(cmd), ("<Command = ['true']\n"
                                " Status  = Exited with return-code 0\n"
                                " STDOUT* = 'pipe_true_{id}.stdout'\n"
                                " STDERR* = 'pipe_true_{id}.stderr'\n"
                                " CWD     = '{temp_dir}'>").format(id = id(cmd),
                                                                   temp_dir = temp_folder))
开发者ID:CarlesV,项目名称:paleomix,代码行数:10,代码来源:pprint_test.py


示例6: test_atomiccmd__pipes_stdin

def test_atomiccmd__pipes_stdin(temp_folder):
    fname = os.path.join("tests", "data", "fasta_file.fasta")
    cmd = AtomicCmd("cat",
                    IN_STDIN   = fname,
                    OUT_STDOUT = "result.txt")
    assert_equal(cmd.input_files, frozenset([fname]))
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    result = get_file_contents(os.path.join(temp_folder, "result.txt"))
    assert_equal(result, ">This_is_FASTA!\nACGTN\n>This_is_ALSO_FASTA!\nCGTNA\n")
开发者ID:CarlesV,项目名称:paleomix,代码行数:10,代码来源:command_test.py


示例7: test_atomiccmd__pipes_stdin__temp_file

def test_atomiccmd__pipes_stdin__temp_file(temp_folder):
    cmd = AtomicCmd("cat",
                    TEMP_IN_STDIN  = "infile.fasta",
                    OUT_STDOUT     = "result.txt")
    assert_equal(cmd.input_files, frozenset())
    set_file_contents(os.path.join(temp_folder, "infile.fasta"), "a\nbc\nd")
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    result = get_file_contents(os.path.join(temp_folder, "infile.fasta"))
    assert_equal(result, "a\nbc\nd")
开发者ID:CarlesV,项目名称:paleomix,代码行数:10,代码来源:command_test.py


示例8: test_atomiccmd__commit_missing_files

def test_atomiccmd__commit_missing_files(temp_folder):
    destination, temp_folder = _setup_for_commit(temp_folder, False)
    cmd = AtomicCmd(("touch", "%(OUT_FOO)s"),
                    OUT_FOO = os.path.join(destination, "1234"),
                    OUT_BAR = os.path.join(destination, "4567"))
    cmd.run(temp_folder)
    cmd.join()
    before = set(os.listdir(temp_folder))
    assert_raises(CmdError, cmd.commit, temp_folder)
    assert_equal(before, set(os.listdir(temp_folder)))
开发者ID:CarlesV,项目名称:paleomix,代码行数:10,代码来源:command_test.py


示例9: _do_test_atomiccmd__paths_temp_in

    def _do_test_atomiccmd__paths_temp_in(temp_folder, set_cwd, kwargs):
        cmd = AtomicCmd(("echo", "-n", "%%(%s)s" % tuple(kwargs.keys())),
                        TEMP_OUT_STDOUT = "result.txt",
                        set_cwd         = set_cwd,
                        **kwargs)
        cmd.run(temp_folder)
        assert_equal(cmd.join(), [0])

        expected = os.path.join("" if set_cwd else temp_folder, "test_file")
        result = get_file_contents(os.path.join(temp_folder, "result.txt"))
        assert_equal(os.path.abspath(expected), os.path.abspath(result))
开发者ID:CarlesV,项目名称:paleomix,代码行数:11,代码来源:command_test.py


示例10: test_commandnode_teardown__missing_optional_files

def test_commandnode_teardown__missing_optional_files(temp_folder):
    destination, temp_folder = _setup_temp_folders(temp_folder)

    cmd = AtomicCmd(("echo", "-n", "1 2 3"),
                    TEMP_OUT_BAR = "bar.txt",
                    OUT_STDOUT = os.path.join(destination, "foo.txt"))
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    node = CommandNode(cmd)
    node._teardown(None, temp_folder)
    assert_equal(os.listdir(temp_folder), [])
    assert_equal(os.listdir(destination), ["foo.txt"])
开发者ID:schae234,项目名称:pypeline,代码行数:12,代码来源:node_test.py


示例11: _do_test_atomiccmd__set_cwd

    def _do_test_atomiccmd__set_cwd(temp_folder, set_cwd):
        cwd = os.getcwd()
        cmd = AtomicCmd(("bash", "-c", "echo -n ${PWD}"),
                        TEMP_OUT_STDOUT = "result.txt",
                        set_cwd         = set_cwd)
        cmd.run(temp_folder)
        assert_equal(cmd.join(), [0])
        assert_equal(cwd, os.getcwd())

        expected = temp_folder if set_cwd else cwd
        result = get_file_contents(os.path.join(temp_folder, "result.txt"))
        assert os.path.samefile(expected, result), "%r != %r" % (expected, result)
开发者ID:CarlesV,项目名称:paleomix,代码行数:12,代码来源:command_test.py


示例12: _do_test_atomiccmd__cleanup_proc

    def _do_test_atomiccmd__cleanup_proc(temp_folder, func):
        assert_equal(pypeline.atomiccmd.command._PROCS, set())
        cmd = AtomicCmd("ls")
        cmd.run(temp_folder)
        ref = iter(pypeline.atomiccmd.command._PROCS).next()
        assert ref
        assert_equal(ref(), cmd._proc)

        assert_equal(cmd.join(), [0])
        cmd = func(cmd, temp_folder)

        assert ref not in pypeline.atomiccmd.command._PROCS
开发者ID:CarlesV,项目名称:paleomix,代码行数:12,代码来源:command_test.py


示例13: test_pformat__simple__done__before_join

def test_pformat__simple__done__before_join(temp_folder):
    cmd = AtomicCmd("true")
    cmd.run(temp_folder)
    cmd._proc.wait() # pylint: disable=W0212
    assert_equal(pformat(cmd), ("<Command = ['true']\n"
                                " Status  = Exited with return-code 0\n"
                                " STDOUT* = '{temp_dir}/pipe_true_{id}.stdout'\n"
                                " STDERR* = '{temp_dir}/pipe_true_{id}.stderr'\n"
                                " CWD     = '{cwd}'>").format(id = id(cmd),
                                                             cwd = os.getcwd(),
                                                             temp_dir = temp_folder))
    assert_equal(cmd.join(), [0])
开发者ID:CarlesV,项目名称:paleomix,代码行数:12,代码来源:pprint_test.py


示例14: test_atomiccmd__piping_is_only_allowed_once

def test_atomiccmd__piping_is_only_allowed_once(temp_folder):
    cmd_1 = AtomicCmd(["echo", "-n", "foo\nbar"],
                      OUT_STDOUT=AtomicCmd.PIPE)
    cmd_2a = AtomicCmd(["grep", "foo"],
                       IN_STDIN=cmd_1)
    cmd_2b = AtomicCmd(["grep", "bar"],
                       IN_STDIN=cmd_1)
    cmd_1.run(temp_folder)
    cmd_2a.run(temp_folder)
    assert_raises(CmdError, cmd_2b.run, temp_folder)
    assert_equal(cmd_1.join(), [0])
    assert_equal(cmd_2a.join(), [0])
    assert_equal(cmd_2b.join(), [None])
开发者ID:CarlesV,项目名称:paleomix,代码行数:13,代码来源:command_test.py


示例15: test_commandnode_teardown

def test_commandnode_teardown(temp_folder):
    destination, temp_folder = _setup_temp_folders(temp_folder)

    cmd = AtomicCmd(("echo", "-n", "1 2 3"),
                    OUT_STDOUT = os.path.join(destination, "foo.txt"))
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    node = CommandNode(cmd)
    assert os.path.exists(os.path.join(temp_folder, "foo.txt"))
    assert not os.path.exists(os.path.join(destination, "foo.txt"))
    node._teardown(None, temp_folder)
    assert not os.path.exists(os.path.join(temp_folder, "foo.txt"))
    assert os.path.exists(os.path.join(destination, "foo.txt"))
开发者ID:schae234,项目名称:pypeline,代码行数:13,代码来源:node_test.py


示例16: test_commandnode_teardown__extra_files_in_temp

def test_commandnode_teardown__extra_files_in_temp(temp_folder):
    destination, temp_folder = _setup_temp_folders(temp_folder)

    cmd = AtomicCmd(("echo", "-n", "1 2 3"),
                    OUT_STDOUT = os.path.join(destination, "foo.txt"))
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    node = CommandNode(cmd)
    set_file_contents(os.path.join(temp_folder, "bar.txt"), "1 2 3")
    temp_files_before = set(os.listdir(temp_folder))
    dest_files_before = set(os.listdir(destination))

    assert_raises(CmdNodeError, node._teardown, None, temp_folder)
    assert_equal(temp_files_before, set(os.listdir(temp_folder)))
    assert_equal(dest_files_before, set(os.listdir(destination)))
开发者ID:schae234,项目名称:pypeline,代码行数:15,代码来源:node_test.py


示例17: _setup_for_commit

def _setup_for_commit(temp_folder, create_cmd = True):
    destination = os.path.join(temp_folder, "out")
    temp_folder = os.path.join(temp_folder, "tmp")
    os.makedirs(destination)
    os.makedirs(temp_folder)

    if not create_cmd:
        return destination, temp_folder

    cmd = AtomicCmd(("touch", "%(OUT_FOO)s"),
                    OUT_FOO = os.path.join(destination, "1234"))
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])

    return destination, temp_folder, cmd
开发者ID:CarlesV,项目名称:paleomix,代码行数:15,代码来源:command_test.py


示例18: test_atomiccmd__ready

def test_atomiccmd__ready(temp_folder):
    cmd = AtomicCmd("ls")
    assert_equal(cmd.join(), [None])
    assert not cmd.ready()
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    assert cmd.ready()
开发者ID:CarlesV,项目名称:paleomix,代码行数:7,代码来源:command_test.py


示例19: _do_test_atomiccmd__stdout

 def _do_test_atomiccmd__stdout(temp_folder, kwargs):
     cmd = AtomicCmd(("echo", "-n", "foo"), **kwargs)
     assert cmd.stdout is None
     cmd.run(temp_folder)
     assert isinstance(cmd.stdout, types.FileType), cmd.stdout
     assert_equal(cmd.stdout.read(), "foo")
     cmd.join()
     cmd.commit(temp_folder)
     assert cmd.stdout is None
开发者ID:schae234,项目名称:pypeline,代码行数:9,代码来源:command_test.py


示例20: test_atomiccmd__piping_temp

def test_atomiccmd__piping_temp(temp_folder):
    cmd_1 = AtomicCmd(["echo", "-n", "#@!$^"],
                        TEMP_OUT_STDOUT = AtomicCmd.PIPE)
    assert_equal(cmd_1.output_files, frozenset())
    cmd_2 = AtomicCmd(["cat"],
                        TEMP_IN_STDIN = cmd_1,
                        OUT_STDOUT = "piped.txt")
    assert_equal(cmd_2.input_files, frozenset())
    cmd_1.run(temp_folder)
    cmd_2.run(temp_folder)
    assert_equal(cmd_1.join(), [0])
    assert_equal(cmd_2.join(), [0])
    result = get_file_contents(os.path.join(temp_folder, "piped.txt"))
    assert_equal(result, "#@!$^")
开发者ID:CarlesV,项目名称:paleomix,代码行数:14,代码来源:command_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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