Exemplo n.º 1
0
    def _test_pipe_composable(self):
        """we should be able to compose pipes of pipes """
        Pipe(Pipe(Sh("echo foo")),
             Pipe(Sh("cat; echo bar")),
             Pipe(Cmd("cat", {1: os.devnull}))).run(),

        self.assertEquals(
            [0,0,0])


        self.assertEquals(len(JOBS), 0)
        " yes | grep no"
        yesno = Pipe(
            Pipe(Cmd('yes')),
            Pipe(Cmd(['grep', 'no']))).spawn()
        yesno.cmds[0].kill()
        self.assertEquals(yesno.cmds[-1].wait(), 1)
        self.assertEquals(yesno.wait(), 1)
        self.assertEquals(len(JOBS), 0)

        pipe_a = Pipe(Cmd('echo foo'))
        pdb.set_trace()
        ab = pipe_a._popen()

        self.assertSh(pipe_a.running_fd_objs[STDOUT].read(), 'foo')
Exemplo n.º 2
0
 def test_spawn(self):
     self.assertEquals(len(JOBS), 0)
     " yes | grep no"
     yesno = Pipe(Cmd('yes'), Cmd(['grep', 'no'])).spawn()
     yesno.cmds[0].kill()
     self.assertEquals(yesno.cmds[-1].wait(), 1)
     self.assertEquals(yesno.wait(), 1)
     self.assertEquals(len(JOBS), 0)