Skip to content

Commit

Permalink
Merge pull request #7209 from aldbr/rel-v7r3_FIX_matplotlib-update
Browse files Browse the repository at this point in the history
[v7r3] fix: ColorBar.draw_all() is replaced by figure.draw_without_rendering()
  • Loading branch information
fstagni authored Sep 27, 2023
2 parents 0c44a0e + 3ca9984 commit 5938d10
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
14 changes: 10 additions & 4 deletions src/DIRAC/Core/Base/Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
6 changes: 5 additions & 1 deletion src/DIRAC/Core/Utilities/Graphs/QualityMapGraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down
28 changes: 24 additions & 4 deletions src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import stat
import time
from collections import defaultdict

import importlib_resources
import six
import subprocess32 as subprocess
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 5938d10

Please sign in to comment.