Re: Terminating python script easily

2009-10-22 Thread Bahadir Balban
On Thu, Oct 22, 2009 at 4:01 PM, Jean-Michel Pichavant
 wrote:
> Balban wrote:
>>
>> Hi,
>>
>> I have a python build script that calls various commands, some using
>> os.system().
>>
>> Often, if I want to terminate the script prematurely, I press ctrl-c,
>> but I have to do this many times before I can kill the script for
>> good. I was wondering is there a way that I define a signal handler
>> and kill the whole thing at once with a single ctrl-c? Perhaps I
>> should  also call my other scripts with a method other than os.system
>> () as well?
>>
>> Thank you,
>>
>> Bahadir
>>
>
> you may want to use subprocess instead of os.system.
> On catching CTRL+C, you kill all the pid started with subprocess and exit
> the script smoothly.
>
> JM
>

Hmm. OK, this is what I suspected I needed. So no explicit signal
catching is required I guess.

I will look into it, thanks.


Bahadir
-- 
http://mail.python.org/mailman/listinfo/python-list


Terminating python script easily

2009-10-22 Thread Balban
Hi,

I have a python build script that calls various commands, some using
os.system().

Often, if I want to terminate the script prematurely, I press ctrl-c,
but I have to do this many times before I can kill the script for
good. I was wondering is there a way that I define a signal handler
and kill the whole thing at once with a single ctrl-c? Perhaps I
should  also call my other scripts with a method other than os.system
() as well?

Thank you,

Bahadir
-- 
http://mail.python.org/mailman/listinfo/python-list


how do I pipe two processes?

2007-02-01 Thread Bilgehan . Balban
Hi, I want to pipe output of process A to B, and read output of B from
python. On Unix if I do the following:

child_out, child_in = popen2("program_a | program_b")

line = child_out.readline()

I get "IOError: bad file descriptor" from Python, and broken pipe
error from program_b. How do I do this right?

Thanks,
Bahadir

-- 
http://mail.python.org/mailman/listinfo/python-list


testing C code with python

2005-11-10 Thread Bilgehan . Balban
Hi,

A simple question - Is it common/good practice to test C code using
Python? For example one could wrap individual C functions, and test
each of them using python, maybe not for low-level things but at least
for algorithmic correctness. Anyone effectively doing this as common
practice?

Thanks,
Bahadir

-- 
http://mail.python.org/mailman/listinfo/python-list