How to use the API?

In that case I would really encourage you to use Yunohost as a Python lib (though that’s assuming that the script runs as root … ) with something like:

import sys
sys.path.insert(0, "/usr/lib/moulinette/")
import yunohost
yunohost.init_logging() # possibly set debug=True if needed, but when writing script supposedly you ain't debugging yunohost itself, and full log is still available in yunohost-cli.log and yunohost log list...
yunohost.init_i18n()

from yunohost.user import user_create

user_create(username="foo", ...)

Note that this is going to be simplified with Bullseye, as Yunohost will be installed similarly to a “regular” python lib in /usr/lib/python3/dist-packages, therefore the two first lines should become uneccesary

1 Like