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"])
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"]
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)
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)