Gabriel Genellina wrote:
> En Wed, 13 Jun 2007 21:47:16 -0300, mike <[EMAIL PROTECTED]> escribió:
> 
>> Following piece of code can capture IOError when the file doesn't
>> exist, also, other unknown exceptions can be captured when I press
>> Ctrl-C while the program is sleeping(time.sleep). Now the question is:
>> when I run the non-exist command, the exception cannot be captured.
> 
>> So far so good, then I changed the code to run a non-exist command
>> "wrong_command_test"(commented the open and sleep lines), then the
>> script printed:
>> sh: wrong_command_test: command not found
>> well Done
> 
> That's because it is not an exception, it is an error message coming 
> from your shell, not from Python.

Of course if you use subprocess.check_call() instead of os.system(), it 
will become an exception (CalledProcessError).
-- 
Michael Hoffman
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to