예제 #1
0
def test_pformat__atomiccmd__simple_with_stdout_pipe():
    cmd = AtomicCmd(("echo", "!"), OUT_STDOUT=AtomicCmd.PIPE)
    assert_equal(pformat(cmd),
                 ("Command = echo '!'\n"
                  "STDOUT  = <PIPE>\n"
                  "STDERR* = '${TEMP_DIR}/pipe_echo_%i.stderr'")
                 % (id(cmd),))
예제 #2
0
def test_pformat__atomiccmd__simple_with_temp_stdin__set_cwd():
    cmd = AtomicCmd("gzip", TEMP_IN_STDIN="stabstabstab", set_cwd=True)
    assert pformat(cmd) == ("Command = gzip\n"
                            "STDIN*  = 'stabstabstab'\n"
                            "STDOUT* = 'pipe_gzip_%i.stdout'\n"
                            "STDERR* = 'pipe_gzip_%i.stderr'\n"
                            "CWD     = '${TEMP_DIR}'") % (id(cmd), id(cmd))
예제 #3
0
def test_pformat__atomiccmd__simple_with_stdin__cmd():
    cmd_1 = AtomicCmd("gzip", OUT_STDOUT=AtomicCmd.PIPE)
    cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
    assert_equal(pformat(cmd_2), ("<Command = ['gzip']\n"
                                  " STDIN   = <PIPE>\n"
                                  " STDOUT* = '${TEMP_DIR}/pipe_gzip_%i.stdout'\n"
                                  " STDERR* = '${TEMP_DIR}/pipe_gzip_%i.stderr'>") % (id(cmd_2), id(cmd_2)))
예제 #4
0
def test_pformat__atomiccmd__simple_with_temp_stdin__set_cwd():
    cmd = AtomicCmd("gzip", TEMP_IN_STDIN="stabstabstab", set_cwd=True)
    assert_equal(pformat(cmd), ("<Command = ['gzip']\n"
                                " STDIN*  = 'stabstabstab'\n"
                                " STDOUT* = 'pipe_gzip_%i.stdout'\n"
                                " STDERR* = 'pipe_gzip_%i.stderr'\n"
                                " CWD     = '${TEMP_DIR}'>") % (id(cmd), id(cmd)))
예제 #5
0
def test_pformat__atomiccmd__simple_with_temp_infile():
    cmd = AtomicCmd(("cat", "%(TEMP_IN_FILE)s"), TEMP_IN_FILE="infile.txt")

    assert pformat(cmd) == ("Command = cat '${TEMP_DIR}/infile.txt'\n"
                            "STDOUT* = '${TEMP_DIR}/pipe_cat_%i.stdout'\n"
                            "STDERR* = '${TEMP_DIR}/pipe_cat_%i.stderr'") % (
                                id(cmd), id(cmd))
예제 #6
0
def test_pformat__atomiccmd__simple_with_stdin():
    cmd = AtomicCmd("gzip", IN_STDIN="/etc/fstab")
    assert pformat(cmd) == ("Command = gzip\n"
                            "STDIN   = '/etc/fstab'\n"
                            "STDOUT* = '${TEMP_DIR}/pipe_gzip_%i.stdout'\n"
                            "STDERR* = '${TEMP_DIR}/pipe_gzip_%i.stderr'") % (
                                id(cmd), id(cmd))
예제 #7
0
def test_pformat__atomiccmd__simple_with_stdout():
    cmd = AtomicCmd(("echo", "Water. Water."), OUT_STDOUT="/dev/ls")
    assert_equal(pformat(cmd),
                 ("Command = echo 'Water. Water.'\n"
                  "STDOUT  = '${TEMP_DIR}/ls'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_echo_%i.stderr'")
                 % (id(cmd),))
예제 #8
0
def test_pformat__atomiccmd__simple_with_temp_stdout():
    cmd = AtomicCmd(("echo", "Oil. Oil."), TEMP_OUT_STDOUT="dm")
    assert_equal(pformat(cmd),
                 ("Command = echo 'Oil. Oil.'\n"
                  "STDOUT* = '${TEMP_DIR}/dm'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_echo_%i.stderr'")
                 % (id(cmd),))
예제 #9
0
def test_pformat__sets__nested():
    cmd_1 = AtomicCmd(("echo", "foo"), OUT_STDOUT=AtomicCmd.PIPE)
    cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
    cmd_3 = AtomicCmd("sha1sum")
    set_1 = ParallelCmds((cmd_1, cmd_2))
    set_2 = SequentialCmds((set_1, cmd_3))
    assert pformat(set_2) == (
        "Sequential processes:\n"
        "  Parallel processes:\n"
        "    Process 1:\n"
        "      Command = echo foo\n"
        "      STDOUT  = Piped to process 2\n"
        "      STDERR* = '${{TEMP_DIR}}/pipe_echo_{cmd_1}.stderr'\n"
        "\n"
        "    Process 2:\n"
        "      Command = gzip\n"
        "      STDIN   = Piped from process 1\n"
        "      STDOUT* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2}.stdout'\n"
        "      STDERR* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2}.stderr'\n"
        "\n"
        "  Process 3:\n"
        "    Command = sha1sum\n"
        "    STDOUT* = '${{TEMP_DIR}}/pipe_sha1sum_{cmd_3}.stdout'\n"
        "    STDERR* = '${{TEMP_DIR}}/pipe_sha1sum_{cmd_3}.stderr'").format(
            cmd_1=id(cmd_1), cmd_2=id(cmd_2), cmd_3=id(cmd_3))
예제 #10
0
def test_pformat__atomiccmd__simple_with_infile():
    cmd = AtomicCmd(("cat", "%(IN_SOMETHING)s"), IN_SOMETHING="/etc/fstab")
    assert_equal(pformat(cmd),
                 ("Command = cat /etc/fstab\n"
                  "STDOUT* = '${TEMP_DIR}/pipe_cat_%i.stdout'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_cat_%i.stderr'")
                 % (id(cmd), id(cmd)))
예제 #11
0
def test_pformat__simple():
    cmd = AtomicCmd(("touch", "something"))
    assert_equal(pformat(cmd),
                 ("Command = touch something\n"
                  "STDOUT* = '${TEMP_DIR}/pipe_touch_%i.stdout'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_touch_%i.stderr'") %
                 (id(cmd), id(cmd)))
예제 #12
0
def test_pformat__atomiccmd__simple_with_outfile():
    cmd = AtomicCmd(("touch", "%(OUT_RC)s"), OUT_RC="/etc/bashrc")
    assert_equal(pformat(cmd),
                 ("Command = touch '${TEMP_DIR}/bashrc'\n"
                  "STDOUT* = '${TEMP_DIR}/pipe_touch_%i.stdout'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_touch_%i.stderr'")
                 % (id(cmd), id(cmd)))
예제 #13
0
def test_pformat__atomiccmd__simple_with_temp_outfile():
    cmd = AtomicCmd(("touch", "%(TEMP_OUT_RC)s"), TEMP_OUT_RC="bashrc")

    assert pformat(cmd) == ("Command = touch '${TEMP_DIR}/bashrc'\n"
                            "STDOUT* = '${TEMP_DIR}/pipe_touch_%i.stdout'\n"
                            "STDERR* = '${TEMP_DIR}/pipe_touch_%i.stderr'") % (
                                id(cmd), id(cmd))
예제 #14
0
def test_pformat__simple():
    cmd = AtomicCmd(("touch", "something"))
    assert_equal(pformat(cmd),
                 ("Command = touch something\n"
                  "STDOUT* = '${TEMP_DIR}/pipe_touch_%i.stdout'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_touch_%i.stderr'")
                 % (id(cmd), id(cmd)))
예제 #15
0
def test_pformat__sets__nested():
    cmd_1 = AtomicCmd(("echo", "foo"), OUT_STDOUT=AtomicCmd.PIPE)
    cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
    cmd_3 = AtomicCmd("sha1sum")
    set_1 = ParallelCmds((cmd_1, cmd_2))
    set_2 = SequentialCmds((set_1, cmd_3))
    assert_equal(pformat(set_2),
                 ("Sequential processes:\n"
                  "  Parallel processes:\n"
                  "    Process 1:\n"
                  "      Command = echo foo\n"
                  "      STDOUT  = Piped to process 2\n"
                  "      STDERR* = '${{TEMP_DIR}}/pipe_echo_{cmd_1}.stderr'\n"
                  "\n"
                  "    Process 2:\n"
                  "      Command = gzip\n"
                  "      STDIN   = Piped from process 1\n"
                  "      STDOUT* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2}.stdout'\n"
                  "      STDERR* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2}.stderr'\n"
                  "\n"
                  "  Process 3:\n"
                  "    Command = sha1sum\n"
                  "    STDOUT* = '${{TEMP_DIR}}/pipe_sha1sum_{cmd_3}.stdout'\n"
                  "    STDERR* = '${{TEMP_DIR}}/pipe_sha1sum_{cmd_3}.stderr'")
                 .format(cmd_1=id(cmd_1),
                         cmd_2=id(cmd_2),
                         cmd_3=id(cmd_3)))
예제 #16
0
def test_pformat__atomiccmd__simple_with_infile__set_cwd():
    cmd = AtomicCmd(("cat", "%(IN_SOMETHING)s"),
                    IN_SOMETHING="/etc/fstab",
                    set_cwd=True)
    assert_equal(pformat(cmd), ("<Command = ['cat', '/etc/fstab']\n"
                                " STDOUT* = 'pipe_cat_%i.stdout'\n"
                                " STDERR* = 'pipe_cat_%i.stderr'\n"
                                " CWD     = '${TEMP_DIR}'>") % (id(cmd), id(cmd)))
예제 #17
0
def test_pformat__atomiccmd__simple_with_temp_stdin():
    cmd = AtomicCmd("gzip", TEMP_IN_STDIN="stabstabstab")
    assert_equal(pformat(cmd),
                 ("Command = gzip\n"
                  "STDIN*  = '${TEMP_DIR}/stabstabstab'\n"
                  "STDOUT* = '${TEMP_DIR}/pipe_gzip_%i.stdout'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_gzip_%i.stderr'")
                 % (id(cmd), id(cmd)))
예제 #18
0
def test_pformat__atomiccmd__simple_with_temp_infile__set_cwd():
    cmd = AtomicCmd(("zcat", "%(TEMP_IN_FILE)s"),
                    TEMP_IN_FILE="infile.gz",
                    set_cwd=True)
    assert_equal(pformat(cmd), ("<Command = ['zcat', 'infile.gz']\n"
                                " STDOUT* = 'pipe_zcat_%i.stdout'\n"
                                " STDERR* = 'pipe_zcat_%i.stderr'\n"
                                " CWD     = '${TEMP_DIR}'>") % (id(cmd), id(cmd)))
예제 #19
0
 def _test_pformat__sets__simple(cls, description):
     cmd_1 = AtomicCmd(("echo", "foo"), OUT_STDOUT=AtomicCmd.PIPE)
     cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
     cmd = cls((cmd_1, cmd_2))
     assert_equal(pformat(cmd),
                  template.format(description=description,
                                  cmd_1_id=id(cmd_1),
                                  cmd_2_id=id(cmd_2)))
예제 #20
0
def test_pformat__atomiccmd__simple_with_temp_stdout__set_cwd():
    cmd = AtomicCmd(("echo", "Room service. Room service."),
                    TEMP_OUT_STDOUT="pv",
                    set_cwd=True)
    assert_equal(pformat(cmd), ("<Command = ['echo', 'Room service. Room service.']\n"
                                " STDOUT* = 'pv'\n"
                                " STDERR* = 'pipe_echo_%i.stderr'\n"
                                " CWD     = '${TEMP_DIR}'>") % (id(cmd),))
예제 #21
0
def test_pformat__atomiccmd__simple_with_infile__set_cwd():
    cmd = AtomicCmd(("cat", "%(IN_SOMETHING)s"),
                    IN_SOMETHING="/etc/fstab",
                    set_cwd=True)
    assert pformat(cmd) == ("Command = cat /etc/fstab\n"
                            "STDOUT* = 'pipe_cat_%i.stdout'\n"
                            "STDERR* = 'pipe_cat_%i.stderr'\n"
                            "CWD     = '${TEMP_DIR}'") % (id(cmd), id(cmd))
예제 #22
0
def test_pformat__atomiccmd__simple_with_stdin__set_cwd():
    cmd = AtomicCmd("gzip", IN_STDIN="/etc/fstab", set_cwd=True)
    assert_equal(pformat(cmd),
                 ("Command = gzip\n"
                  "STDIN   = '/etc/fstab'\n"
                  "STDOUT* = 'pipe_gzip_%i.stdout'\n"
                  "STDERR* = 'pipe_gzip_%i.stderr'\n"
                  "CWD     = '${TEMP_DIR}'") % (id(cmd), id(cmd)))
예제 #23
0
def test_pformat__atomiccmd__simple_with_temp_stdin():
    cmd = AtomicCmd("gzip", TEMP_IN_STDIN="stabstabstab")
    assert_equal(pformat(cmd),
                 ("Command = gzip\n"
                  "STDIN*  = '${TEMP_DIR}/stabstabstab'\n"
                  "STDOUT* = '${TEMP_DIR}/pipe_gzip_%i.stdout'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_gzip_%i.stderr'") %
                 (id(cmd), id(cmd)))
예제 #24
0
def test_pformat__atomiccmd__simple_with_stdout__set_cwd():
    cmd = AtomicCmd(("echo", "*pant*. *pant*."),
                    OUT_STDOUT="/dev/barf", set_cwd=True)
    assert_equal(pformat(cmd),
                 ("Command = echo '*pant*. *pant*.'\n"
                  "STDOUT  = 'barf'\n"
                  "STDERR* = 'pipe_echo_%i.stderr'\n"
                  "CWD     = '${TEMP_DIR}'") % (id(cmd),))
예제 #25
0
def test_pformat__atomiccmd__simple_with_temp_stdout__set_cwd():
    cmd = AtomicCmd(("echo", "Room service. Room service."),
                    TEMP_OUT_STDOUT="pv",
                    set_cwd=True)
    assert pformat(cmd) == ("Command = echo 'Room service. Room service.'\n"
                            "STDOUT* = 'pv'\n"
                            "STDERR* = 'pipe_echo_%i.stderr'\n"
                            "CWD     = '${TEMP_DIR}'") % (id(cmd), )
예제 #26
0
def test_pformat__atomiccmd__simple_with_stdin__cmd():
    cmd_1 = AtomicCmd("gzip", OUT_STDOUT=AtomicCmd.PIPE)
    cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
    assert pformat(cmd_2) == (
        "Command = gzip\n"
        "STDIN   = <PIPE>\n"
        "STDOUT* = '${TEMP_DIR}/pipe_gzip_%i.stdout'\n"
        "STDERR* = '${TEMP_DIR}/pipe_gzip_%i.stderr'") % (id(cmd_2), id(cmd_2))
예제 #27
0
def test_pformat__atomiccmd__simple_with_stdout__set_cwd():
    cmd = AtomicCmd(("echo", "*pant*. *pant*."),
                    OUT_STDOUT="/dev/barf",
                    set_cwd=True)
    assert pformat(cmd) == ("Command = echo '*pant*. *pant*.'\n"
                            "STDOUT  = 'barf'\n"
                            "STDERR* = 'pipe_echo_%i.stderr'\n"
                            "CWD     = '${TEMP_DIR}'") % (id(cmd), )
예제 #28
0
 def _test_pformat__sets__simple(cls, description):
     cmd_1 = AtomicCmd(("echo", "foo"), OUT_STDOUT=AtomicCmd.PIPE)
     cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
     cmd = cls((cmd_1, cmd_2))
     assert_equal(
         pformat(cmd),
         template.format(description=description,
                         cmd_1_id=id(cmd_1),
                         cmd_2_id=id(cmd_2)))
예제 #29
0
def test_pformat__atomiccmd__simple_with_temp_infile():
    cmd = AtomicCmd(("cat", "%(TEMP_IN_FILE)s"),
                    TEMP_IN_FILE="infile.txt")

    assert_equal(pformat(cmd),
                 ("Command = cat '${TEMP_DIR}/infile.txt'\n"
                  "STDOUT* = '${TEMP_DIR}/pipe_cat_%i.stdout'\n"
                  "STDERR* = '${TEMP_DIR}/pipe_cat_%i.stderr'")
                 % (id(cmd), id(cmd)))
예제 #30
0
def test_pformat__atomiccmd__simple_with_stdin__set_cwd():
    cmd = AtomicCmd("gzip", IN_STDIN="/etc/fstab", set_cwd=True)
    assert_equal(pformat(cmd),
                 ("Command = gzip\n"
                  "STDIN   = '/etc/fstab'\n"
                  "STDOUT* = 'pipe_gzip_%i.stdout'\n"
                  "STDERR* = 'pipe_gzip_%i.stderr'\n"
                  "CWD     = '${TEMP_DIR}'")
                 % (id(cmd), id(cmd)))
예제 #31
0
def test_pformat__atomiccmd__simple_with_temp_infile__set_cwd():
    cmd = AtomicCmd(("zcat", "%(TEMP_IN_FILE)s"),
                    TEMP_IN_FILE="infile.gz",
                    set_cwd=True)

    assert pformat(cmd) == ("Command = zcat infile.gz\n"
                            "STDOUT* = 'pipe_zcat_%i.stdout'\n"
                            "STDERR* = 'pipe_zcat_%i.stderr'\n"
                            "CWD     = '${TEMP_DIR}'") % (id(cmd), id(cmd))
예제 #32
0
def test_pformat__atomiccmd__simple_with_temp_outfile__set_cwd():
    cmd = AtomicCmd(("touch", "%(TEMP_OUT_RC)s"),
                    TEMP_OUT_RC="bashrc",
                    set_cwd=True)

    assert pformat(cmd) == ("Command = touch bashrc\n"
                            "STDOUT* = 'pipe_touch_%i.stdout'\n"
                            "STDERR* = 'pipe_touch_%i.stderr'\n"
                            "CWD     = '${TEMP_DIR}'") % (id(cmd), id(cmd))
예제 #33
0
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))
예제 #34
0
def test_pformat__simple__done__set_cwd(tmp_path):
    cmd = AtomicCmd("true", set_cwd=True)
    cmd.run(tmp_path)
    assert cmd.join() == [0]
    assert 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=tmp_path)
예제 #35
0
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()
예제 #36
0
def test_pformat__simple__running__set_cwd(tmp_path):
    cmd = AtomicCmd(("sleep", "10"), set_cwd=True)
    cmd.run(tmp_path)
    assert 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=tmp_path)
    cmd.terminate()
    cmd.join()
예제 #37
0
def test_pformat__simple__temp_root_in_arguments(tmp_path):
    cmd = AtomicCmd(("echo", "${TEMP_DIR}"))
    cmd.run(tmp_path)
    assert cmd.join() == [0]
    assert 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=tmp_path,
                                                        cwd=os.getcwd())
예제 #38
0
def test_pformat__atomiccmd__simple_with_temp_outfile__set_cwd():
    cmd = AtomicCmd(("touch", "%(TEMP_OUT_RC)s"),
                    TEMP_OUT_RC="bashrc",
                    set_cwd=True)

    assert_equal(pformat(cmd),
                 ("Command = touch bashrc\n"
                  "STDOUT* = 'pipe_touch_%i.stdout'\n"
                  "STDERR* = 'pipe_touch_%i.stderr'\n"
                  "CWD     = '${TEMP_DIR}'")
                 % (id(cmd), id(cmd)))
예제 #39
0
def test_pformat__simple__done__before_join(tmp_path):
    cmd = AtomicCmd("true")
    cmd.run(tmp_path)
    cmd._proc.wait()
    assert 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=tmp_path)
    assert cmd.join() == [0]
예제 #40
0
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))
예제 #41
0
def test_pformat__simple__killed(temp_folder):
    cmd = AtomicCmd(("sleep", "10"))
    cmd.run(temp_folder)
    cmd.terminate()
    assert_equal(cmd.join(), ["SIGTERM"])
    assert_equal(pformat(cmd), ("<Command = ['sleep', '10']\n"
                                " Status  = Terminated with signal SIGTERM\n"
                                " STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
                                " STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
                                " CWD     = '{cwd}'>").format(id=id(cmd),
                                                              temp_dir=temp_folder,
                                                              cwd=os.getcwd()))
예제 #42
0
def test_pformat__simple__killed_by_signal(tmp_path):
    cmd = AtomicCmd(("sleep", "10"))
    cmd.run(tmp_path)
    os.killpg(cmd._proc.pid, signal.SIGTERM)
    assert cmd.join() == ["SIGTERM"]
    assert pformat(cmd) == ("Command = sleep 10\n"
                            "Status  = Terminated with signal SIGTERM\n"
                            "STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
                            "STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
                            "CWD     = '{cwd}'").format(id=id(cmd),
                                                        temp_dir=tmp_path,
                                                        cwd=os.getcwd())
예제 #43
0
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))
예제 #44
0
def test_pformat__simple__terminated_by_pipeline(tmp_path):
    cmd = AtomicCmd(("sleep", "10"))
    cmd.run(tmp_path)
    cmd.terminate()
    assert cmd.join() == ["SIGTERM"]
    assert pformat(cmd) == ("Command = sleep 10\n"
                            "Status  = Automatically terminated by PALEOMIX\n"
                            "STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
                            "STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
                            "CWD     = '{cwd}'").format(id=id(cmd),
                                                        temp_dir=tmp_path,
                                                        cwd=os.getcwd())
예제 #45
0
def test_pformat__simple__running(temp_folder):
    cmd = AtomicCmd(("sleep", "10"))
    cmd.run(temp_folder)
    assert_equal(pformat(cmd),
                 ("Command = sleep 10\n"
                  "Status  = Running ...\n"
                  "STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
                  "STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
                  "CWD     = '{cwd}'").format(id=id(cmd),
                                              cwd=os.getcwd(),
                                              temp_dir=temp_folder))
    cmd.terminate()
    cmd.join()
예제 #46
0
def test_pformat__simple__terminated_by_pipeline(temp_folder):
    cmd = AtomicCmd(("sleep", "10"))
    cmd.run(temp_folder)
    cmd.terminate()
    assert_equal(cmd.join(), ["SIGTERM"])
    assert_equal(pformat(cmd),
                 ("Command = sleep 10\n"
                  "Status  = Automatically terminated by PALEOMIX\n"
                  "STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
                  "STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
                  "CWD     = '{cwd}'").format(id=id(cmd),
                                              temp_dir=temp_folder,
                                              cwd=os.getcwd()))
예제 #47
0
def test_pformat__simple__running(temp_folder):
    cmd = AtomicCmd(("sleep", "10"))
    cmd.run(temp_folder)
    assert_equal(pformat(cmd),
                 ("Command = sleep 10\n"
                  "Status  = Running ...\n"
                  "STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
                  "STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
                  "CWD     = '{cwd}'").format(id=id(cmd),
                                              cwd=os.getcwd(),
                                              temp_dir=temp_folder))
    cmd.terminate()
    cmd.join()
예제 #48
0
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()))
예제 #49
0
def test_pformat__simple__done__before_join(temp_folder):
    cmd = AtomicCmd("true")
    cmd.run(temp_folder)
    # pylint: disable=protected-access
    cmd._proc.wait()
    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])
예제 #50
0
def test_pformat__simple__killed_by_signal(temp_folder):
    cmd = AtomicCmd(("sleep", "10"))
    cmd.run(temp_folder)
    # pylint: disable=protected-access
    os.killpg(cmd._proc.pid, signal.SIGTERM)
    assert_equal(cmd.join(), ["SIGTERM"])
    assert_equal(pformat(cmd),
                 ("Command = sleep 10\n"
                  "Status  = Terminated with signal SIGTERM\n"
                  "STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
                  "STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
                  "CWD     = '{cwd}'").format(id=id(cmd),
                                              temp_dir=temp_folder,
                                              cwd=os.getcwd()))
예제 #51
0
def test_pformat__simple__killed_by_signal(temp_folder):
    cmd = AtomicCmd(("sleep", "10"))
    cmd.run(temp_folder)
    # pylint: disable=protected-access
    os.killpg(cmd._proc.pid, signal.SIGTERM)
    assert_equal(cmd.join(), ["SIGTERM"])
    assert_equal(pformat(cmd),
                 ("Command = sleep 10\n"
                  "Status  = Terminated with signal SIGTERM\n"
                  "STDOUT* = '{temp_dir}/pipe_sleep_{id}.stdout'\n"
                  "STDERR* = '{temp_dir}/pipe_sleep_{id}.stderr'\n"
                  "CWD     = '{cwd}'").format(id=id(cmd),
                                              temp_dir=temp_folder,
                                              cwd=os.getcwd()))
예제 #52
0
def test_pformat__simple__done__before_join(temp_folder):
    cmd = AtomicCmd("true")
    cmd.run(temp_folder)
    # pylint: disable=protected-access
    cmd._proc.wait()
    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])
예제 #53
0
 def _do_test_pformat__sets__simple(cls, description):
     cmd_1 = AtomicCmd(("echo", "foo"), OUT_STDOUT=AtomicCmd.PIPE)
     cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
     cmd = cls((cmd_1, cmd_2))
     assert_equal(pformat(cmd),
                  ("<{description}:\n"
                   "  - <00> Command = ['echo', 'foo']\n"
                   "         STDOUT  = <01>\n"
                   "         STDERR* = '${{TEMP_DIR}}/pipe_echo_{cmd_1_id}.stderr'\n"
                   "  - <01> Command = ['gzip']\n"
                   "         STDIN   = <00>\n"
                   "         STDOUT* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2_id}.stdout'\n"
                   "         STDERR* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2_id}.stderr'>")
                  .format(description=description,
                          cmd_1_id=id(cmd_1),
                          cmd_2_id=id(cmd_2)))
예제 #54
0
def test_pformat__sets__simple(cls, description):
    template = ("{description}:\n"
                "  Process 1:\n"
                "    Command = echo foo\n"
                "    STDOUT  = Piped to process 2\n"
                "    STDERR* = '${{TEMP_DIR}}/pipe_echo_{cmd_1_id}.stderr'\n"
                "\n"
                "  Process 2:\n"
                "    Command = gzip\n"
                "    STDIN   = Piped from process 1\n"
                "    STDOUT* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2_id}.stdout'\n"
                "    STDERR* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2_id}.stderr'")

    cmd_1 = AtomicCmd(("echo", "foo"), OUT_STDOUT=AtomicCmd.PIPE)
    cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
    cmd = cls((cmd_1, cmd_2))
    assert pformat(cmd) == template.format(description=description,
                                           cmd_1_id=id(cmd_1),
                                           cmd_2_id=id(cmd_2))
예제 #55
0
def test_pformat__sets__nested():
    cmd_1 = AtomicCmd(("echo", "foo"), OUT_STDOUT=AtomicCmd.PIPE)
    cmd_2 = AtomicCmd("gzip", IN_STDIN=cmd_1)
    cmd_3 = AtomicCmd("sha1sum")
    set_1 = ParallelCmds((cmd_1, cmd_2))
    set_2 = SequentialCmds((set_1, cmd_3))
    assert_equal(pformat(set_2),
                 ("<Sequential commands:\n"
                  "  - Parallel commands:\n"
                  "      - <00> Command = ['echo', 'foo']\n"
                  "             STDOUT  = <01>\n"
                  "             STDERR* = '${{TEMP_DIR}}/pipe_echo_{cmd_1_id}.stderr'\n"
                  "      - <01> Command = ['gzip']\n"
                  "             STDIN   = <00>\n"
                  "             STDOUT* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2_id}.stdout'\n"
                  "             STDERR* = '${{TEMP_DIR}}/pipe_gzip_{cmd_2_id}.stderr'\n"
                  "  - <02> Command = ['sha1sum']\n"
                  "         STDOUT* = '${{TEMP_DIR}}/pipe_sha1sum_{cmd_3_id}.stdout'\n"
                  "         STDERR* = '${{TEMP_DIR}}/pipe_sha1sum_{cmd_3_id}.stderr'>")
                 .format(cmd_1_id=id(cmd_1),
                         cmd_2_id=id(cmd_2),
                         cmd_3_id=id(cmd_3)))
예제 #56
0
def test_pformat__bad_input(value):
    with pytest.raises(TypeError):
        pformat(value)
예제 #57
0
파일: sets.py 프로젝트: tmancill/paleomix
 def __str__(self):
     return atomicpp.pformat(self)
예제 #58
0
def test_pformat__atomiccmd__simple_with_stdout_pipe():
    cmd = AtomicCmd(("echo", "!"), OUT_STDOUT=AtomicCmd.PIPE)
    assert pformat(
        cmd) == ("Command = echo '!'\n"
                 "STDOUT  = <PIPE>\n"
                 "STDERR* = '${TEMP_DIR}/pipe_echo_%i.stderr'") % (id(cmd), )
예제 #59
0
 def __str__(self):
     return atomicpp.pformat(self)
예제 #60
0
def test_pformat__atomiccmd__simple_with_temp_stdout():
    cmd = AtomicCmd(("echo", "Oil. Oil."), TEMP_OUT_STDOUT="dm")
    assert pformat(
        cmd) == ("Command = echo 'Oil. Oil.'\n"
                 "STDOUT* = '${TEMP_DIR}/dm'\n"
                 "STDERR* = '${TEMP_DIR}/pipe_echo_%i.stderr'") % (id(cmd), )