From b32c343a0c36f9c3a541cc933e1786915ae6d3e7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 7 Jun 2022 10:35:08 -0400 Subject: [PATCH] Switch to importlib for newer python imp is deprecated, despite being much simpler, so use importlib in python3.6+ distributions. --- .../el8/profiles/default/scripts/add_local_repositories | 8 ++++++-- .../profiles/default/scripts/add_local_repositories | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/confluent_osdeploy/el8/profiles/default/scripts/add_local_repositories b/confluent_osdeploy/el8/profiles/default/scripts/add_local_repositories index 2e128b47..e9cc5e9a 100644 --- a/confluent_osdeploy/el8/profiles/default/scripts/add_local_repositories +++ b/confluent_osdeploy/el8/profiles/default/scripts/add_local_repositories @@ -3,9 +3,13 @@ try: except ImportError: import ConfigParser as configparser import cStringIO -import imp +import importlib.util +import importlib.machinery import sys -apiclient = imp.load_source('apiclient', '/opt/confluent/bin/apiclient') +modloader = importlib.machinery.SourceFileLoader('apiclient', '/opt/confluent/bin/apiclient') +modspec = importlib.util.spec_from_file_location('apiclient', '/opt/confluent/bin/apiclient', loader=modloader) +apiclient = importlib.util.module_from_spec(modspec) +modspec.loader.exec_module(apiclient) repo = None server = None profile = None diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/add_local_repositories b/confluent_osdeploy/el9-diskless/profiles/default/scripts/add_local_repositories index 2e128b47..e9cc5e9a 100644 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/add_local_repositories +++ b/confluent_osdeploy/el9-diskless/profiles/default/scripts/add_local_repositories @@ -3,9 +3,13 @@ try: except ImportError: import ConfigParser as configparser import cStringIO -import imp +import importlib.util +import importlib.machinery import sys -apiclient = imp.load_source('apiclient', '/opt/confluent/bin/apiclient') +modloader = importlib.machinery.SourceFileLoader('apiclient', '/opt/confluent/bin/apiclient') +modspec = importlib.util.spec_from_file_location('apiclient', '/opt/confluent/bin/apiclient', loader=modloader) +apiclient = importlib.util.module_from_spec(modspec) +modspec.loader.exec_module(apiclient) repo = None server = None profile = None