diff --git a/lib/gen_call_robot.py b/lib/gen_call_robot.py index 6521af2..01ce611 100755 --- a/lib/gen_call_robot.py +++ b/lib/gen_call_robot.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. +# Copyright (c) 2023-2025, Arm Limited or its affiliates. All rights reserved. # SPDX-License-Identifier : Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,7 @@ robot program calls. """ -import imp +import importlib.util import os import re import subprocess @@ -33,7 +33,7 @@ import gen_valid as gv base_path = ( - os.path.dirname(os.path.dirname(imp.find_module("gen_robot_print")[1])) + os.path.dirname(os.path.dirname(importlib.util.find_spec("gen_robot_print").origin)) + os.sep ) diff --git a/lib/gen_misc.py b/lib/gen_misc.py index f66d526..c7058a9 100755 --- a/lib/gen_misc.py +++ b/lib/gen_misc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. +# Copyright (c) 2023-2025, Arm Limited or its affiliates. All rights reserved. # SPDX-License-Identifier : Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,14 +31,8 @@ import sys import time -try: - import ConfigParser -except ImportError: - import configparser -try: - import StringIO -except ImportError: - import io +import configparser +from io import StringIO import re import socket @@ -320,14 +314,11 @@ def my_parm_file(prop_file_path): string_file.seek(0, os.SEEK_SET) # Create the ConfigParser object. - try: - config_parser = ConfigParser.ConfigParser() - except NameError: - config_parser = configparser.ConfigParser(strict=False) + config_parser = configparser.ConfigParser(strict=False) # Make the property names case-sensitive. config_parser.optionxform = str # Read the properties from the string file. - config_parser.readfp(string_file) + config_parser.read_file(string_file) # Return the properties as a dictionary. if robot_env: return DotDict(config_parser.items("dummysection")) diff --git a/lib/logging_utils.py b/lib/logging_utils.py index 555d75c..f38c915 100644 --- a/lib/logging_utils.py +++ b/lib/logging_utils.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. +# Copyright (c) 2023-2025, Arm Limited or its affiliates. All rights reserved. # SPDX-License-Identifier : Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +19,7 @@ Provide useful error log utility keywords. """ -import imp +import importlib.util import os import sys @@ -27,7 +27,7 @@ from robot.libraries.BuiltIn import BuiltIn base_path = ( - os.path.dirname(os.path.dirname(imp.find_module("gen_robot_print")[1])) + os.path.dirname(os.path.dirname(importlib.util.find_spec("gen_robot_print").origin)) + os.sep ) sys.path.append(base_path + "data/") diff --git a/lib/obmc_boot_test.py b/lib/obmc_boot_test.py index f165000..364dde9 100755 --- a/lib/obmc_boot_test.py +++ b/lib/obmc_boot_test.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. +# Copyright (c) 2023-2025, Arm Limited or its affiliates. All rights reserved. # SPDX-License-Identifier : Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +20,7 @@ """ import glob -import imp +import importlib.util import os import random import re @@ -50,7 +50,7 @@ from robot.utils import DotDict base_path = ( - os.path.dirname(os.path.dirname(imp.find_module("gen_robot_print")[1])) + os.path.dirname(os.path.dirname(importlib.util.find_spec("gen_robot_print").origin)) + os.sep ) sys.path.append(base_path + "extended/") diff --git a/lib/state.py b/lib/state.py index 88cefa8..1f09013 100755 --- a/lib/state.py +++ b/lib/state.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -# Copyright (c) 2023, Arm Limited or its affiliates. All rights reserved. +# Copyright (c) 2023-2025, Arm Limited or its affiliates. All rights reserved. # SPDX-License-Identifier : Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,7 +42,7 @@ compared with the expected state. """ -import imp +import importlib.util import os import re import sys @@ -56,7 +56,7 @@ from robot.utils import DotDict base_path = ( - os.path.dirname(os.path.dirname(imp.find_module("gen_robot_print")[1])) + os.path.dirname(os.path.dirname(importlib.util.find_spec("gen_robot_print").origin)) + os.sep ) sys.path.append(base_path + "data/") diff --git a/requirements.txt b/requirements.txt index 991884f..d812f44 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ click PyYAML>=5.1 redfishtool robotframework-selenium2library -webdrivermanager +webdriver-manager robotframework-angularjs robotframework-xvfb redfish_utilities