Skip to content

Commit

Permalink
fix: ColorBar.draw_all() is replaced by figure.draw_without_rendering()
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed Sep 19, 2023
1 parent 0c44a0e commit efc958e
Show file tree
Hide file tree
Showing 3 changed files with 20 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 @@ -9,6 +9,7 @@
__RCSID__ = "$Id$"

import ast
import sys
from functools import partial

try:
Expand All @@ -22,7 +23,13 @@ def __get__(self, instance, owner):
return partial(self.func, instance, *(self.args or ()), **(self.keywords or {}))


import importlib_resources
from importlib_resources import files

if sys.version_info.major > 3:
from importlib_resources import as_file # pylint: disable=no-member
else:
from importlib_resources import path as as_file

import six

from DIRAC.Core.Tornado.Client.ClientSelector import RPCClientSelector
Expand Down Expand Up @@ -167,9 +174,8 @@ def addFunctions(clientCls):
attrDict = dict(clientCls.__dict__)
for extension in extensionsByPriority():
try:
path = importlib_resources.path(
"%s.%sSystem.Service" % (extension, systemName),
"%s.py" % handlerModuleName,
path = as_file(
files("%s.%sSystem.Service" % (extension, systemName)).joinpath("%s.py" % handlerModuleName)
)
fullHandlerClassPath = "%s.%s" % (extension, handlerClassPath)
with path as fp:
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 sys
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 sys.version_info.major < 3:
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
9 changes: 5 additions & 4 deletions src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@
import re
import shutil
import stat
import sys
import time
from collections import defaultdict
from importlib_resources import files

import importlib_resources
import six
import subprocess32 as subprocess
from diraccfg import CFG
Expand Down Expand Up @@ -845,7 +846,7 @@ def getComponentCfg(
for ext in extensions:
cfgTemplateModule = "%s.%sSystem" % (ext, system)
try:
cfgTemplate = importlib_resources.read_text(cfgTemplateModule, "ConfigTemplate.cfg")
cfgTemplate = 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 +2196,7 @@ 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)
dbSql = files(moduleName).joinpath(filename).read_text(encoding="utf-8")

# just check
result = self.execMySQL("SHOW STATUS")
Expand Down Expand Up @@ -2295,7 +2296,7 @@ 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)
dbSourced = 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 efc958e

Please sign in to comment.