当前位置: 首页>>代码示例>>Python>>正文


Python AtomicCmd.run方法代码示例

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


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

示例1: test_atomiccmd__paths__key

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
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:MikkelSchubert,项目名称:paleomix,代码行数:9,代码来源:command_test.py

示例2: test_atomiccmd__ready

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
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:MikkelSchubert,项目名称:paleomix,代码行数:9,代码来源:command_test.py

示例3: test_atomiccmd__commit_before_join

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
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:MikkelSchubert,项目名称:paleomix,代码行数:9,代码来源:command_test.py

示例4: test_atomiccmd__terminate_race_condition

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
def test_atomiccmd__terminate_race_condition(temp_folder):
    cmd = AtomicCmd("true")
    cmd.run(temp_folder)
    while cmd._proc.poll() is None:
        pass
    cmd.terminate()
    assert_equal(cmd.join(), [0])
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:9,代码来源:command_test.py

示例5: test_atomiccmd__paths_non_str

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
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:MikkelSchubert,项目名称:paleomix,代码行数:9,代码来源:command_test.py

示例6: _do_test_atomiccmd__pipes_out

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
 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:muslih14,项目名称:paleomix,代码行数:10,代码来源:command_test.py

示例7: test_atomiccmd__commit_temp_only

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
def test_atomiccmd__commit_temp_only(temp_folder):
    cmd = AtomicCmd(("echo", "foo"),
                    TEMP_OUT_STDOUT="bar.txt")
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    assert os.path.exists(os.path.join(temp_folder, "bar.txt"))
    cmd.commit(temp_folder)
    assert_equal(os.listdir(temp_folder), [])
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:10,代码来源:command_test.py

示例8: test_pformat__simple__done__set_cwd

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
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:muslih14,项目名称:paleomix,代码行数:12,代码来源:pprint_test.py

示例9: test_atomiccmd__pipes_stdin

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
def test_atomiccmd__pipes_stdin(temp_folder):
    fname = test_file("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:muslih14,项目名称:paleomix,代码行数:12,代码来源:command_test.py

示例10: test_atomiccmd__commit_missing_files

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
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:MikkelSchubert,项目名称:paleomix,代码行数:12,代码来源:command_test.py

示例11: test_atomiccmd__pipes_stdin__temp_file

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
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, "result.txt"))
    assert_equal(result, "a\nbc\nd")
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:12,代码来源:command_test.py

示例12: test_pformat__simple__running__set_cwd

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
def test_pformat__simple__running__set_cwd(temp_folder):
    cmd = AtomicCmd(("sleep", "10"), set_cwd=True)
    cmd.run(temp_folder)
    assert_equal(pformat(cmd), ("<Command = ['sleep', '10']\n"
                                " Status  = Running ...\n"
                                " STDOUT* = 'pipe_sleep_{id}.stdout'\n"
                                " STDERR* = 'pipe_sleep_{id}.stderr'\n"
                                " CWD     = '{temp_dir}'>").format(id=id(cmd),
                                                                   temp_dir=temp_folder))
    cmd.terminate()
    cmd.join()
开发者ID:muslih14,项目名称:paleomix,代码行数:13,代码来源:pprint_test.py

示例13: _test_atomiccmd__paths_temp_in

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
    def _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:MikkelSchubert,项目名称:paleomix,代码行数:13,代码来源:command_test.py

示例14: test_atomiccmd__commit_temp_out

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
def test_atomiccmd__commit_temp_out(temp_folder):
    dest, temp = _setup_for_commit(temp_folder, create_cmd=False)
    cmd = AtomicCmd(("echo", "foo"),
                    OUT_STDOUT=os.path.join(dest, "foo.txt"),
                    TEMP_OUT_FOO="bar.txt")
    cmd.run(temp)
    assert_equal(cmd.join(), [0])
    set_file_contents(os.path.join(temp, "bar.txt"), "1 2 3")
    cmd.commit(temp)
    assert_equal(os.listdir(temp), [])
    assert_equal(os.listdir(dest), ["foo.txt"])
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:13,代码来源:command_test.py

示例15: _do_test_atomiccmd__cleanup_proc

# 需要导入模块: from paleomix.atomiccmd.command import AtomicCmd [as 别名]
# 或者: from paleomix.atomiccmd.command.AtomicCmd import run [as 别名]
    def _do_test_atomiccmd__cleanup_proc(temp_folder, func):
        assert_equal(paleomix.atomiccmd.command._PROCS, set())
        cmd = AtomicCmd("ls")
        cmd.run(temp_folder)
        ref = iter(paleomix.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 paleomix.atomiccmd.command._PROCS
开发者ID:MikkelSchubert,项目名称:paleomix,代码行数:14,代码来源:command_test.py


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