cliutils 0.1 released: Helpful utilities for Python shell scripts
written by Ian McCracken
at Thursday, September 18, 2008
Last weekend I had the idea to make a decorator that parsed
I packaged these up into an egg and released it in the Cheese Shop, so you can get it with:
Code hosted at Google Code. And here are the API docs.
I'll be adding to this package as I come up with other tidbits that make shell scripts easier to write. After work today, provided I finish the project I'm working on, I plan to write a tutorial on packaging up one's own shell scripts in eggs for easier deployment and PYTHONPATH mungery. Setuptools really does make it incredibly easy.
sys.argv
and passed the results as args to functions referenced by setuptools-created shell scripts. That turned out to be trivially easy. For some reason, I ended up writing a logging decorator, that redirects stdout to a given file-like object, and a much more ambitious Process object, which wraps subprocess.Popen
objects and allows them to be piped into each other like in bash:>>> p = Process("echo 'blah blah blah'") | Process("wc -w")
>>> print p.stdout
3
I packaged these up into an egg and released it in the Cheese Shop, so you can get it with:
$ easy_install cliutils
Code hosted at Google Code. And here are the API docs.
I'll be adding to this package as I come up with other tidbits that make shell scripts easier to write. After work today, provided I finish the project I'm working on, I plan to write a tutorial on packaging up one's own shell scripts in eggs for easier deployment and PYTHONPATH mungery. Setuptools really does make it incredibly easy.
October 12, 2009 at 3:59 PM
don't like?::
>>>import commands
>>>print commands.getoutput("echo blah blah blah | wc -w")
3