Re: [Tutor] feedback on writing pipelines in python

2012-03-22 Thread Wayne Werner

On Wed, 21 Mar 2012, Abhishek Pratap wrote:

Hi Guys
I am  in the process of perl to python transition for
good.


Welcome!


1. stitch pipelines : I want python to act as a glue
allowing me to run various linux shell based programs.
If needed wait for a program to finish and then move on,
logs if required 


You'll want to take a look at the subprocess module. One thing you will notice
is that Perl has a lot more terse syntax when it comes to commands line
integration. That being said, Python is still fully capable.

 You may want to check out an Oreilly book called Python for the system 
administrator by Noah Gift. It doesn't tell you much about each tool but 
it exposes you to a ton of them.


HTH,
Wayne___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] feedback on writing pipelines in python

2012-03-21 Thread Abhishek Pratap
Hi Steve

I agree Steve perl is perfectly fine for the stuff I described but I am
also interested trying alternatives. I am seeing quite interesting data
handling stuff coming up in Python and I would like to try and sometimes as
a programmer I dont like so many ways of doing the same things but it is
subjective. Having many options can be good for some.


-Abhi



On Wed, Mar 21, 2012 at 11:20 AM, Steve Willoughby st...@alchemy.comwrote:

 On 21-Mar-12 11:03, Abhishek Pratap wrote:

 Hi Guys

 I am  in the process of perl to python transition for good.  I wanted to


 Why?  Perl is still a perfectly good tool.  Just not, IMHO, good for
 exactly the same things Python is good for.


  1. stitch pipelines : I want python to act as a glue allowing me to run
 various linux shell based programs. If needed wait for a program to
 finish and then move on, logs if required


 Look at the subprocess standard library module.  It offers a complete set
 of options for launching processes, piping their data aound, waiting for
 them, handling exceptions, and so forth.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] feedback on writing pipelines in python

2012-03-21 Thread Steve Willoughby

On 21-Mar-12 11:03, Abhishek Pratap wrote:

Hi Guys

I am  in the process of perl to python transition for good.  I wanted to


Why?  Perl is still a perfectly good tool.  Just not, IMHO, good for 
exactly the same things Python is good for.



1. stitch pipelines : I want python to act as a glue allowing me to run
various linux shell based programs. If needed wait for a program to
finish and then move on, logs if required


Look at the subprocess standard library module.  It offers a complete 
set of options for launching processes, piping their data aound, waiting 
for them, handling exceptions, and so forth.


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] feedback on writing pipelines in python

2012-03-21 Thread Alan Gauld

On 21/03/12 18:03, Abhishek Pratap wrote:


1. stitch pipelines : I want python to act as a glue allowing me to run
various linux shell based programs. If needed wait for a program to
finish and then move on, logs if required


Python by default reads/writes to stdin/stdout so you can do stuff like:

$ foo.py  fred.txt | bar.py | baz.py  joe.txt

You can also control that explicitly by importing the sys module and 
reassigning sys.stdin/sys.stdout or even reading and writing explicitly 
from those file like objects.


You can also use the subprocess module to execute other programs (either 
Python or any other ind of executable file) in a sub procvess or a 
separate shell and get full control over the pipes, stdin, stdout and 
stderr. Of course that flexibility brings a price and the full power of 
subprocess.Popen is a little complex but there are lots of examples in 
the documentation.



2. run the same pipeline but on a local grid if required. (SGE flavor
mainly)


I confess I have no idea what you mean by a local grid, or an
SGE flavor thereof...

Somebody else will need to address that one!

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor