Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions XSConsoleImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import imp, os, re, sys, traceback
import importlib.util, os, re, sys, traceback

from XSConsoleLog import *
from XSConsoleMenus import *
Expand Down Expand Up @@ -46,8 +46,10 @@ def ImportAbsDir(cls, inDir):
try:
try:
# Import using variable as module name
(fileObj, pathName, description) = imp.find_module(importName, [root])
imp.load_module(importName, fileObj, pathName, description)
spec = importlib.util.spec_from_file_location(
importName, os.path.join(root, filename))
module = importlib.util.module_from_spec(spec)
module.__loader__.exec_module(module)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is preferred to use loader rather than __loader__ here. See https://docs.python.org/3.14/library/importlib.html#importlib.machinery.ModuleSpec.loader and the examples in that document.

Otherwise this PR looks fine to me.

except Exception as e:
try: XSLogError(*traceback.format_tb(sys.exc_info()[2]))
except: pass
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name = "XSConsole"
dynamic = ["version"]
description = "Xenserver Status Report"
requires-python = "2.7"
requires-python = ">=3.6"
license = "GPL-2.0-or-later"
keywords = ["xenserver", "xen-project"]
authors = [
Expand All @@ -19,15 +19,14 @@ readme = "README.md"
classifiers = [
"Environment :: Console",
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: GNU General Public License v2 (GPLv2) or later",
"Operating System :: POSIX :: Linux :: XenServer/XCP-ng Dom0",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: System :: Logging",
"Topic :: System :: Monitoring",
Expand Down