Re: lib389 devel notes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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.

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@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to 389-devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxxxxx
_______________________________________________
389-devel mailing list -- 389-devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to 389-devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Directory Announce]     [Fedora Users]     [Older Fedora Users Mail]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Review]     [Fedora Art]     [Fedora Music]     [Fedora Packaging]     [CentOS]     [Fedora SELinux]     [Big List of Linux Books]     [KDE Users]     [Fedora Art]     [Fedora Docs]

  Powered by Linux