From 8b8ffad490aff54fd141dcd4fb6110c9e4d64c7a Mon Sep 17 00:00:00 2001 From: Daniela Bauer Date: Thu, 20 Jul 2023 13:03:39 +0100 Subject: [PATCH] fix: replaced deprecated importlib read_text function --- src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py b/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py index 48810c4d9f5..16c7cbeb594 100644 --- a/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py +++ b/src/DIRAC/FrameworkSystem/Client/ComponentInstaller.py @@ -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) @@ -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") @@ -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())