[Freeipa-devel] [PATCH] 0091 ipautil.run: Log the command line before running the command

Petr Viktorin pviktori at redhat.com
Tue Oct 16 14:27:51 UTC 2012


On 10/16/2012 04:02 PM, Jan Cholasta wrote:
> Hi,
>
> On 15.10.2012 14:45, Petr Viktorin wrote:
>> As I was debugging code that calls long-running or failing commands, I
>> got tired of the invocation being logged after the command is done.
>> This patch should improve the logging.
>>
>> https://fedorahosted.org/freeipa/ticket/3174
>> ---
>> Petr³
>>
>
> +    except:
> +        root_logger.debug('Process failed')
> +        raise
>
> Why do you use blank except here? Can you print the reason why the
> process has failed or the exit code here?
>
> Honza
>

I re-raise command afterwards, so the error is not really handled or 
ignored. It's one of the few situations where a bare except is justified :)
Since the error is re-raised, it should be handled by the caller. 
Printing additional info here should be redundant.
The exception can happen before the Popen object is created, so the 
return code might not be available. Anyway bad return code is handled 
later, here we'd get errors like command not found, fork() failure etc.

I see that the wording could be better, attaching new patch:
s/Process failed/Process execution failed/
s/Process successful/Process finished/

-- 
Petr³

-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeipa-pviktori-0091-02-ipautil.run-Log-the-command-line-before-running-the-.patch
Type: text/x-patch
Size: 2231 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20121016/ca98b7b5/attachment.bin>


More information about the Freeipa-devel mailing list