From 5b14270d0d01730d8f55339e6e9ea393c71ba49c Mon Sep 17 00:00:00 2001 From: Tiemen Schuijbroek Date: Fri, 10 Jul 2020 05:10:44 +0200 Subject: [PATCH] Fix cherrypy CherryPyWSGIServer import (#301) CherryPy changed the import location. This attempts the new or falls back to the old location. Co-authored-by: Tiemen Schuijbroek --- pypiserver/bottle.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pypiserver/bottle.py b/pypiserver/bottle.py index 96ca3e4..4d3271b 100644 --- a/pypiserver/bottle.py +++ b/pypiserver/bottle.py @@ -2792,7 +2792,10 @@ class WSGIRefServer(ServerAdapter): class CherryPyServer(ServerAdapter): def run(self, handler): # pragma: no cover - from cherrypy import wsgiserver + try: + from cheroot.wsgi import Server as CherryPyWSGIServer + except ImportError: + from cherrypy.wsgiserver import CherryPyWSGIServer self.options['bind_addr'] = (self.host, self.port) self.options['wsgi_app'] = handler @@ -2803,7 +2806,7 @@ class CherryPyServer(ServerAdapter): if keyfile: del self.options['keyfile'] - server = wsgiserver.CherryPyWSGIServer(**self.options) + server = CherryPyWSGIServer(**self.options) if certfile: server.ssl_certificate = certfile if keyfile: