New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python hooks reloaded #747
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't tested, but look good to me.
099827f
to
8c4d136
Compare
Merging soonish |
|
||
# TODO : We might want to check here that it's a tuple | ||
# containing an int + a dict ? | ||
ret = module.main(args, env, loggers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we spawn a new python process that launch the python instead of calling it in the current python process? That would be better security and bug wise I think (but idk how hard would it be to do that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I kinda chose to do this because that's supposedly less ressource expensive, considering that we're likely to import code from yunohost's in each of those (e.g. 10~15ish hooks in the context of diagnosis), each likely to do stuff like importing requests
or other libs that take hell of time to load on RPi for example
Proposing to merge soonish in 3.7 (not really needed or anything but at least that becomes stable code upon which the migration mechanism can be built and possibly other things) |
The problem
This is a rewrite of #535 because there were too many changes ... :
Python hooks are required for the new diagnosis system modularity / extendability, and more generally if we want to implement some hooks in python for some reason. This could be the case for example of the famous
app ssowatconf
command which should be a classical regen-conf thing but can't be so far because it has too many python calls and json stuff to be implemented in bash.Solution
Split the behavior of the
hook_exec
function depending on the nature of the hook. Python hooks are to be modules loaded by yunohost and expected to have amain
function.PR Status
Tested and working
How to test
Create some hook with a main function (e.g. just displaying
hello world
) and callyunohost hook list your_hook_type
andyunohost diagnosis callback your_hook_type
Validation