From: John Spray Date: Fri, 27 Apr 2018 10:56:21 +0000 (-0400) Subject: mgr/dashboard: fix linter complaints X-Git-Tag: v13.1.0~25^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5596f489dad762b5399bac087d8125b2ebfcf74f;p=ceph.git mgr/dashboard: fix linter complaints In addition to line ordering, there were a couple of bogus ones: E: 30, 0: No name 'version' in module 'distutils' (no-name-in-module) E: 30, 0: Unable to import 'distutils.version' (import-error) E: 36, 8: No name 'wsgiserver' in module 'cherrypy' (no-name-in-module) E: 36, 8: Unable to import 'cherrypy.wsgiserver.wsgiserver2' (import-error) I don't know why pylint can't see these modules, but they're definitely there, so I've added them to the ignored list in .pylintrc Signed-off-by: John Spray --- diff --git a/src/pybind/mgr/dashboard/.pylintrc b/src/pybind/mgr/dashboard/.pylintrc index 96f88facc3fd..b3616b4c876c 100644 --- a/src/pybind/mgr/dashboard/.pylintrc +++ b/src/pybind/mgr/dashboard/.pylintrc @@ -407,7 +407,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. -ignored-modules= +ignored-modules=cherrypy,distutils # Show a hint with possible names when a member name was not found. The aspect # of finding the hint is based on edit distance. diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 8e7c16a20e83..8f4a542e0622 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -5,13 +5,17 @@ openATTIC mgr plugin (based on CherryPy) from __future__ import absolute_import import errno +from distutils.version import StrictVersion import os import socket import tempfile import threading from uuid import uuid4 + from OpenSSL import crypto +from mgr_module import MgrModule, MgrStandbyModule + try: from urlparse import urljoin except ImportError: @@ -27,7 +31,6 @@ except ImportError: # The SSL code in CherryPy 3.5.0 is buggy. It was fixed long ago, # but 3.5.0 is still shipping in major linux distributions # (Fedora 27, Ubuntu Xenial), so we must monkey patch it to get SSL working. -from distutils.version import StrictVersion if cherrypy is not None: v = StrictVersion(cherrypy.__version__) # It was fixed in 3.7.0. Exact lower bound version is probably earlier, @@ -35,6 +38,7 @@ if cherrypy is not None: if v >= StrictVersion("3.5.0") and v < StrictVersion("3.7.0"): from cherrypy.wsgiserver.wsgiserver2 import HTTPConnection,\ CP_fileobject + def fixed_init(hc_self, server, sock, makefile=CP_fileobject): hc_self.server = server hc_self.socket = sock @@ -45,8 +49,6 @@ if cherrypy is not None: HTTPConnection.__init__ = fixed_init -from mgr_module import MgrModule, MgrStandbyModule - if 'COVERAGE_ENABLED' in os.environ: import coverage _cov = coverage.Coverage(config_file="{}/.coveragerc".format(os.path.dirname(__file__))) @@ -93,6 +95,9 @@ class SSLCherryPyConfig(object): self._stopping = threading.Event() self._url_prefix = "" + self.cert_tmp = None + self.pkey_tmp = None + def shutdown(self): self._stopping.set() @@ -191,6 +196,7 @@ class SSLCherryPyConfig(object): self.log.info("Configured CherryPy, starting engine...") return uri + class Module(MgrModule, SSLCherryPyConfig): """ dashboard module entrypoint