Hi,
We are using custom event scripts written using PythonAPI to work with our shotgunEventDaemon and at times we see that there is a lot of common python code which could be abstracted in to its own module and then can be re-used in the custom scripts rather than duplicating them over and over again
Is there a recommended location in the shotgunEventDaemon repository (cloned, of course and deployed as a service internally) which could then be imported?
In its current state, if we create a module in shotgun/src/shotgun/events/custom/, we get erros like “Did not find a registerCallbacks function in plugin” as probably the Daemon expects any script in that location to have registerCallbacks method !
3 Likes
Hi @nvadapalli
You can put any common code in a normal python module that lives on your Python path. One way that I find rather simple that I often suggest is the following organization:
- Create a separate source code repository for your plugins
- Make sure you have a
plugins
and modules
folder in your repository
- Configure your daemon’s plugin path to point to your repository’s
plugins
folder
- Put any common code modules in your
modules
folder
- Make sure that the environment your daemon runs in has a properly configured
PYTHONPATH
that points to the modules
directory
At this point, you’ve got a cloned repository for the daemon which you can easily update and a separate repository for your custom code.
One thing to be mindful of is that when you update your plugins’ code, the daemon will reload them automatically. If you update code in a shared module, the daemon won’t see this and you’ll need to restart the daemon manually.
Sure hope this helps you make your plugin code more manageable.
Cheers,
Patrick
4 Likes
Hi Patrick,
That is really helpful ! I will try to find a way that modules
is actually available in daemon’s environment, other than using sys.path.append
Thanks for the suggestion.
Regards,
Naren
2 Likes