query backends from installed packages #106
Conversation
This is an example backend as an external package that when installed along with netjsonconfig will let the user choose the |
I greatly support this patch as it's The Right Way To Do it :P Please merge :) |
try: | ||
default.update({entry_point.name.lower(): entry_point.load()}) | ||
except ImportError as e: | ||
print("Error loading backend {}".format(entry_point.name.lower()), file=sys.stderr) |
redhog
May 31, 2018
Shouldn't this rather use the python logging framework?
Shouldn't this rather use the python logging framework?
edoput
May 31, 2018
•
Author
Contributor
in the grand scheme of integrating with openwisp-contoller it should use whatever openwisp-config is using? I don't really know what is the correct way to log this but I didn't want crash to propagate to netjsonconfig when loading. Moreover loggin requires to choose a target (console, file, syslog, ...) and a level and I'm not sure which should they be,
in the grand scheme of integrating with openwisp-contoller it should use whatever openwisp-config is using? I don't really know what is the correct way to log this but I didn't want crash to propagate to netjsonconfig when loading. Moreover loggin requires to choose a target (console, file, syslog, ...) and a level and I'm not sure which should they be,
redhog
May 31, 2018
•
django-netjsonconfig/utils.py:9 uses
import logging
logger = logging.getLogger(__name__)
logger.warning("Grrrrrr")
django-netjsonconfig/utils.py:9 uses
import logging
logger = logging.getLogger(__name__)
logger.warning("Grrrrrr")
edoput
May 31, 2018
Author
Contributor
Ok I'll change this to be a logger on the console 👍
Ok I'll change this to be a logger on the console
Let me know if there's anything else to do or I'll squash everything before merge |
Looks good :) |
this will use the entry_points feature of pkg_resources to query other installed packages for additional backends. - [doc] added page create_your_backend - prevent import errors from crashing the cli during load the module will be imported but if an ImportError is raised the cli crash. This will prevent the cli from crashing but will not expose the backend to the user. An error message will be logger to console - exclude except form from flake qa this form is the only one compatible between python2 and python3 but flake is also worried about the e variable which is not used
@edoput great job |
Hi all,
this will solve a problem that I had last summer during GSOC. Using
entry_points
in the definitionof
setup.py
we can query possible backends for use in netjsonconfig in other packages instead of having long-lived branches.This is an example for a
setup.py
using theentry_points
directive