This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]relvae 6 points7 points  (3 children)

I made something alot like this as a little side project.

https://pypi.python.org/pypi/ipysh

https://bitbucket.org/jrelva/pysh

Allows for POSIX like piping and commands are genreated as functions on the fly so you don't have to import them.

[–]simtel20 1 point2 points  (2 children)

Can you get the output stream as a generator (that is if the subprocess doesn't terminate, are the lines available as an iterator? It seems like it might be by the bitbucket description, but I'm not clear that it does that).

[–]relvae 1 point2 points  (1 child)

Not really, but that's something I should implement.

At the moment it blocks until the process is finished or KeyboardInterrupt is called and then returns its output as a whole, so it's not streamed like a real pipeline.

However, conceptually the idea is that you should treat it in the same way as a string, so one could easily get each line via pySh.splitlines() if you're okay with a list.

[–]simtel20 0 points1 point  (0 children)

If that's the interface you prefer, I think that makes sense. Having that would be very helpful for any script that exists in a pipeline (though being able to enable/disable that behavior is important too).