コード例 #1
0
    def test_session(self):
        sh = local.session()
        for _ in range(4):
            _, out, _ = sh.run("ls -a")
            self.assertTrue("test_local.py" in out.splitlines())

        sh.run("cd ..")
        sh.run("export FOO=17")
        out = sh.run("echo $FOO")[1]
        self.assertEqual(out.splitlines(), ["17"])
コード例 #2
0
ファイル: test_local.py プロジェクト: adamchainz/plumbum
    def test_session(self):
        sh = local.session()
        for _ in range(4):
            _, out, _ = sh.run("ls -a")
            self.assertTrue("test_local.py" in out.splitlines())

        sh.run("cd ..")
        sh.run("export FOO=17")
        out = sh.run("echo $FOO")[1]
        self.assertEqual(out.splitlines(), ["17"])
コード例 #3
0
ファイル: test_local.py プロジェクト: lovejavaee/plumbum
    def test_session(self):
        sh = local.session()
        for _ in range(4):
            _, out, _ = sh.run("ls -a")
            assert "test_local.py" in out.splitlines()

        sh.run("cd ..")
        sh.run("export FOO=17")
        out = sh.run("echo $FOO")[1]
        assert out.splitlines() == ["17"]
コード例 #4
0
    def run(self, cmd, retcode=None):
        return run_proc(self.popen(cmd), retcode)


if __name__ == "__main__":
    from plumbum import local
    from plumbum.cmd import ls, date, sleep
    c = ls & date & sleep[1]
    print(c())

    c = ls & date & sleep[1] & sleep["-z"]
    try:
        c()
    except ProcessExecutionError as ex:
        print(ex)
    else:
        assert False

    clst = Cluster(local, local, local)
    print(clst["ls"]())

    # This works fine
    print(local.session().run("echo $$"))

    # this does not
    ret, stdout, stderr = clst.session().run("echo $$")
    print(ret)
    ret = [int(pid) for pid in stdout]
    assert (len(set(ret)) == 3)
コード例 #5
0
ファイル: parallel.py プロジェクト: AinuX/plumbum
    c = ls & date & sleep[1]
    print(c())

    c = ls & date & sleep[1] & sleep["-z"]
    try:
        c()
    except ProcessExecutionError as ex:
        print(ex)
    else:
        assert False

    clst = Cluster(local, local, local)
    print(clst["ls"]())


    # This works fine
    print(local.session().run("echo $$"))

    # this does not
    ret, stdout, stderr = clst.session().run("echo $$")
    print(ret)
    ret = [int(pid) for pid in stdout]
    assert(len(set(ret))==3)