diff --git a/src/DIRAC/Core/Base/Client.py b/src/DIRAC/Core/Base/Client.py index 5fa4e4ba2bb..52d4af52065 100644 --- a/src/DIRAC/Core/Base/Client.py +++ b/src/DIRAC/Core/Base/Client.py @@ -167,10 +167,16 @@ def addFunctions(clientCls): attrDict = dict(clientCls.__dict__) for extension in extensionsByPriority(): try: - path = importlib_resources.path( - "%s.%sSystem.Service" % (extension, systemName), - "%s.py" % handlerModuleName, - ) + if six.PY3: + path = importlib_resources.as_file( + importlib_resources.files("%s.%sSystem.Service" % (extension, systemName)).joinpath( + "%s.py" % handlerModuleName + ) + ) + else: + path = importlib_resources.path( + "%s.%sSystem.Service" % (extension, systemName), "%s.py" % handlerModuleName + ) # pylint: disable=no-member fullHandlerClassPath = "%s.%s" % (extension, handlerClassPath) with path as fp: handlerAst = ast.parse(fp.read_text(), str(path)) diff --git a/src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py b/src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py index 809b33f119e..6bc8e154642 100644 --- a/src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py +++ b/src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py @@ -8,6 +8,7 @@ from __future__ import print_function import datetime +import six from pylab import setp from matplotlib.colors import Normalize import matplotlib.cm as cm @@ -181,7 +182,10 @@ def draw(self): cb = ColorbarBase( cax, cmap=self.cmap, norm=self.norms, boundaries=self.cbBoundaries, values=self.cbValues, ticks=self.cbTicks ) - cb.draw_all() + if six.PY2: + cb.draw_all() # pylint: disable=no-member + else: + self.figure.draw_without_rendering() # cb = self.ax.colorbar( self.mapper, format="%d%%", # orientation='horizontal', fraction=0.04, pad=0.1, aspect=40 ) # setp( cb.outline, linewidth=.5 ) diff --git a/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py b/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py index 4208aa35140..952a41ad3a4 100644 --- a/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py +++ b/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py @@ -74,7 +74,6 @@ import stat import time from collections import defaultdict - import importlib_resources import six import subprocess32 as subprocess @@ -845,7 +844,16 @@ def getComponentCfg( for ext in extensions: cfgTemplateModule = "%s.%sSystem" % (ext, system) try: - cfgTemplate = importlib_resources.read_text(cfgTemplateModule, "ConfigTemplate.cfg") + if six.PY2: + cfgTemplate = importlib_resources.read_text( + cfgTemplateModule, "ConfigTemplate.cfg" + ) # pylint: disable=no-member + else: + cfgTemplate = ( + importlib_resources.files(cfgTemplateModule) + .joinpath("ConfigTemplate.cfg") + .read_text(encoding="utf-8") + ) except (ImportError, OSError): continue gLogger.notice("Loading configuration template from", cfgTemplateModule) @@ -2195,7 +2203,10 @@ def installDatabase(self, dbName): systemName = databases[filename] moduleName = ".".join([extension, systemName, "DB"]) gLogger.debug("Installing %s from %s" % (filename, moduleName)) - dbSql = importlib_resources.read_text(moduleName, filename) + if six.PY2: + dbSql = importlib_resources.read_text(moduleName, filename) # pylint: disable=no-member + else: + dbSql = importlib_resources.files(moduleName).joinpath(filename).read_text(encoding="utf-8") # just check result = self.execMySQL("SHOW STATUS") @@ -2295,7 +2306,16 @@ def _createMySQLCMDLines(self, dbSql): sourcedDBbFileName = line.split(" ")[1].replace("\n", "") gLogger.info("Found file to source: %s" % sourcedDBbFileName) module, filename = sourcedDBbFileName.rsplit("/", 1) - dbSourced = importlib_resources.read_text(module.replace("/", "."), filename) + if six.PY2: + dbSourced = importlib_resources.read_text( + module.replace("/", "."), filename + ) # pylint: disable=no-member + else: + dbSourced = ( + importlib_resources.files(module.replace("/", ".")) + .joinpath(filename) + .read_text(encoding="utf-8") + ) for lineSourced in dbSourced.split("\n"): if lineSourced.strip(): cmdLines.append(lineSourced.strip())