On 06/03/2012 11:08 PM, guyanhua wrote:
>>> + else:
>>> + return cmd_result.exit_status, cmd_result.stdout.strip()
>>
>> What do you think about just returning cmd_result here? Then the caller
>> has the flexibility to decide what data is important and it keeps
>> virsh_cmd() simple.
>
> I also hope so, but some virsh_cmd() callers'
> return-result(cmd_result.stdout.strip())
> has already been directly used in other functions, thus changing-work
> will be huge!
>

Ahh yes, good point and lmr dislikes function that return different 
types depending on parameters. But, we could combine returns into a 
string.  I wonder, could we get away with something like this:

if raise_error:
     return "#####STDOUT:\n%s\n#####STDERR:\n%s\n#####EXIT:%d" %
            (cmd_result.stdout.strip(), cmd_result.stderr.strip(),
            cmd_result.exit_status)
else:
     return cmd_result.stdout.strip()

It may take a bit of extra processing (maybe we make a utility 
function?) on the callers part, but at least it would always return a 
string.  How about this approach?

-- 
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to