Closed bsuttor closed 2 years ago
Thanks for reporting and I see you are already working on this.
What about changing:
except (
pkg_resources.DistributionNotFound,
pkg_resources.RequirementParseError,
):
pass
to
except Exception:
warnings.error("Cannot parse version for %r", self.request.get("SERVER_SOFTWARE"))
Goal is to avoid breakage and to make devs aware that something has to be fixed without spamming them
A warning helps yes. And I do not use the warnings
module often enough.
It should be warnings.warn
though. error
does not exist.
What is a bit weird/sad though, is that the InvalidRequirement
exception that @bsuttor gets, is not caught by the try/except RequirementParseError
. From a pdbpp
session it looks like this would be meant to work. Maybe it worked in earlier Python versions.
(Pdb++) pkg_resources.extern.packaging.requirements.InvalidRequirement?
Type: type
String Form: <class 'pkg_resources.extern.packaging.requirements.InvalidRequirement'>
File: /Users/maurits/community/plone-coredev/6.0/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/requirements.py
Docstring:
An invalid requirement was found, users should refer to PEP 508.
Constructor information:
Docstring: Initialize self. See help(type(self)) for accurate signature.
(Pdb++) pkg_resources.RequirementParseError?
Type: type
String Form: <class 'pkg_resources.RequirementParseError'>
File: /Users/maurits/community/plone-coredev/6.0/lib/python3.9/site-packages/pkg_resources/__init__.py
Docstring: Compatibility wrapper for InvalidRequirement
Constructor information:
Docstring: Initialize self. See help(type(self)) for accurate signature.
Thank you @ale-rt ,
There is another related PR on buildout.coredev, Indeed, I was not able to start buildout ./bin/buildout -c wsgioptions.cfg
because of not compatible version of greenlet with python 3.9: https://github.com/plone/buildout.coredev/pull/777
Would you like another PR to use
except Exception:
warnings.warn("Cannot parse version for %r", self.request.get("SERVER_SOFTWARE"))
instead of
except (
pkg_resources.DistributionNotFound,
pkg_resources.RequirementParseError,
):
pass
?
It would be great if you have time to do that!
I'm working on it, but I have one question, for my new test, gunicorn is needed into test eggs. But I don't know where is the best place to add it. Is it in the test section of setup.py of Products.CMFPlone or into buildout.cordev ? I think it's related of Products.CMFPlone, so maybe it's better to put gunicorn in setup.py file ?
BUG/PROBLEM REPORT (OR OTHER COMMON ISSUE)
overview-controlpanel view do not work with gunicorn. This view get server_name from
SERVER_SOFTWARE
environment variable and try to parse this name to get version from pkg_resources. (https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/controlpanel/browser/overview.py#L55)As I can see in Gunicorn,
SERVER_SOFTWARE
variable is equal to "gunicorn/19.9.0" (https://github.com/benoitc/gunicorn/blob/19.x/gunicorn/__init__.py#L8) which is not parsable for pkg_resources.What I did:
I start buildout coredev with wsgioptions.cfg config file and start gunicorn-instance like that:
then create a Plone site and go to http://localhost:8080/Plone/overview-controlpanel
What I expect to happen:
overview-controlpanel view with all information about server (gunicorn version, plone version, python version, ...)
What actually happened:
a template error
What version of Plone/ Addons I am using:
6.0.0a3