On 31 Jan 2019, at 13:34, Mark Reynolds <mreynolds(a)redhat.com>
wrote:
On 1/30/19 9:16 PM, William Brown wrote:
> Hi,
>
> I noticed a few things that seem out of place in lib389’s cli tools. I just want to
point out that using raw print isn’t really correct. Using log allows us to capture the
written output for test verification, so always use log, not print.
We have to use print() because the logging causes all kinds of issues with CLI
interaction. Mainly you can not redirect it as you would expect, there were other issues
too but I don't recall them at the moment. I think there was a double logging issue
as well? The only viable option at the time was to use to print() for the CLI tool's
output.
No problem. I think this is a stdout/stderr issue as you say, but we can tell the logger
to use stdout. I’ll put that into the PR as well.
>
> If you are then writing a function on a lib389 dsldapobject, you shouldn’t directly
log the output either. You should return it (probably as a dict!) to the caller. This way
the caller can either display/format the object correctly *or* they can consume the data
in further functions. Even more important, by simply returning a dict, you can consume the
_json magic. I saw an example where get_attr_vals was used, and then ensure_str called,
then json transformed. The better way would have been to use get_attr_vals_utf8_json()
which would have done all the correct wrapping and transformation for you :)
>
> I know it seems nitpicky, but little details like this matter for testing and api
cleanliness and reuse in future applications :)
>
> Thanks,
>
> —
> Sincerely,
>
> William Brown
> Software Engineer, 389 Directory Server
> SUSE Labs
> _______________________________________________
> 389-devel mailing list -- 389-devel(a)lists.fedoraproject.org
> To unsubscribe send an email to 389-devel-leave(a)lists.fedoraproject.org
> Fedora Code of Conduct:
https://getfedora.org/code-of-conduct.html
> List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives:
https://lists.fedoraproject.org/archives/list/389-devel@lists.fedoraproje...
—
Sincerely,
William Brown
Software Engineer, 389 Directory Server
SUSE Labs