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


Python command.AtomicCmd類代碼示例

本文整理匯總了Python中paleomix.atomiccmd.command.AtomicCmd的典型用法代碼示例。如果您正苦於以下問題:Python AtomicCmd類的具體用法?Python AtomicCmd怎麽用?Python AtomicCmd使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: 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:MikkelSchubert,項目名稱:paleomix,代碼行數:7,代碼來源:command_test.py

示例2: 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:MikkelSchubert,項目名稱:paleomix,代碼行數:7,代碼來源:command_test.py

示例3: 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:MikkelSchubert,項目名稱: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:muslih14,項目名稱:paleomix,代碼行數:8,代碼來源:command_test.py

示例5: 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, "result.txt"))
    assert_equal(result, "a\nbc\nd")
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:10,代碼來源:command_test.py

示例6: 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:MikkelSchubert,項目名稱:paleomix,代碼行數:10,代碼來源:command_test.py

示例7: 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:muslih14,項目名稱:paleomix,代碼行數:10,代碼來源:pprint_test.py

示例8: test_atomiccmd__pipes_stdin

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,代碼行數:10,代碼來源:command_test.py

示例9: _test_atomiccmd__paths_temp_in

    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,代碼行數:11,代碼來源:command_test.py

示例10: _do_test_atomiccmd__cleanup_proc

    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,代碼行數:12,代碼來源:command_test.py

示例11: test_pformat__simple__done

def test_pformat__simple__done(temp_folder):
    cmd = AtomicCmd("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* = '{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))
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:12,代碼來源:pprint_test.py

示例12: _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:muslih14,項目名稱:paleomix,代碼行數:12,代碼來源:command_test.py

示例13: 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"),
                    IN_DUMMY=_EMPTY_FILE,
                    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:MikkelSchubert,項目名稱:paleomix,代碼行數:13,代碼來源:node_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:MikkelSchubert,項目名稱:paleomix,代碼行數:13,代碼來源:command_test.py

示例15: test_pformat__simple__temp_root_in_arguments

def test_pformat__simple__temp_root_in_arguments(temp_folder):
    cmd = AtomicCmd(("echo", "${TEMP_DIR}"))
    cmd.run(temp_folder)
    assert_equal(cmd.join(), [0])
    assert_equal(pformat(cmd),
                 ("Command = echo '{temp_dir}'\n"
                  "Status  = Exited with return-code 0\n"
                  "STDOUT* = '{temp_dir}/pipe_echo_{id}.stdout'\n"
                  "STDERR* = '{temp_dir}/pipe_echo_{id}.stderr'\n"
                  "CWD     = '{cwd}'")
                 .format(id=id(cmd),
                         temp_dir=temp_folder,
                         cwd=os.getcwd()))
開發者ID:MikkelSchubert,項目名稱:paleomix,代碼行數:13,代碼來源:pprint_test.py


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