Skip to content

Commit

Permalink
Merge pull request #7112 from ic-hep/compinstaller
Browse files Browse the repository at this point in the history
[8.0] fix: replaced deprecated importlib read_text function
  • Loading branch information
fstagni authored Jul 24, 2023
2 parents 5e5b1af + 8b8ffad commit 4aa3fd4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,9 @@ def getComponentCfg(
for ext in extensions:
cfgTemplateModule = f"{ext}.{system}System"
try:
cfgTemplate = importlib_resources.read_text(cfgTemplateModule, "ConfigTemplate.cfg")
cfgTemplate = (
importlib_resources.files(cfgTemplateModule).joinpath("ConfigTemplate.cfg").read_text()
)
except (ImportError, OSError):
continue
gLogger.notice("Loading configuration template from", cfgTemplateModule)
Expand Down Expand Up @@ -2128,7 +2130,7 @@ def installDatabase(self, dbName):
systemName = databases[filename]
moduleName = ".".join([extension, systemName, "DB"])
gLogger.debug(f"Installing {filename} from {moduleName}")
dbSql = importlib_resources.read_text(moduleName, filename)
dbSql = importlib_resources.files(moduleName).joinpath(filename).read_text()

# just check
result = self.execMySQL("SHOW STATUS")
Expand Down Expand Up @@ -2228,7 +2230,7 @@ def _createMySQLCMDLines(self, dbSql):
sourcedDBbFileName = line.split(" ")[1].replace("\n", "")
gLogger.info(f"Found file to source: {sourcedDBbFileName}")
module, filename = sourcedDBbFileName.rsplit("/", 1)
dbSourced = importlib_resources.read_text(module.replace("/", "."), filename)
dbSourced = importlib_resources.files(module.replace("/", ".")).joinpath(filename).read_text()
for lineSourced in dbSourced.split("\n"):
if lineSourced.strip():
cmdLines.append(lineSourced.strip())
Expand Down

0 comments on commit 4aa3fd4

Please sign in to comment.