From bd593b8df76db090a7bafc1032175475c90a25a3 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sat, 28 Sep 2024 21:11:13 +0900 Subject: [PATCH] Fix undefined names This fixes apparent problems detected when F821 check is enabled. ./packstack/installer/core/drones.py:43:16: F821 undefined name 'ScriptRuntimeError' except ScriptRuntimeError as ex: ^ ./packstack/installer/core/drones.py:313:9: F821 undefined name 'shutil' shutil.rmtree(self.local_tmpdir, ignore_errors=True) ./packstack/installer/run_setup.py:115:37: F821 undefined name 'raw_input' userInput = raw_input(message.read()) ^ ./packstack/installer/run_setup.py:194:15: F821 undefined name 'raw_input' raw = raw_input(message.read()) ^ ./tests/installer/test_drones.py:82:23: F821 undefined name 'tarfile' tarball = tarfile.open(pack_path) ^ Change-Id: Ie100fa47472c2bd55635d5b4a524cf9ef6671940 --- packstack/installer/core/drones.py | 3 ++- packstack/installer/run_setup.py | 4 ++-- tests/installer/test_drones.py | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packstack/installer/core/drones.py b/packstack/installer/core/drones.py index 6fe85ffc7..c7c911ac8 100644 --- a/packstack/installer/core/drones.py +++ b/packstack/installer/core/drones.py @@ -13,6 +13,7 @@ # limitations under the License. import os +import shutil import stat import uuid import time @@ -40,7 +41,7 @@ class SshTarballTransferMixin(object): "tar -C %(res_dir)s -xpzf %(pack_dest)s" % args) try: script.execute() - except ScriptRuntimeError as ex: + except utils.ScriptRuntimeError as ex: # TO-DO: change to appropriate exception raise RuntimeError('Failed to copy resources to node %s. ' 'Reason: %s' % (node, ex)) diff --git a/packstack/installer/run_setup.py b/packstack/installer/run_setup.py index b12817147..2fb46b483 100644 --- a/packstack/installer/run_setup.py +++ b/packstack/installer/run_setup.py @@ -112,7 +112,7 @@ def _getInputFromUser(param): if (param.MASK_INPUT): userInput = getpass.getpass("%s :" % (param.PROMPT)) else: - userInput = raw_input(message.read()) + userInput = input(message.read()) else: userInput = commandLineValues[param.CONF_NAME] # If DEFAULT_VALUE is set and user did not input anything @@ -191,7 +191,7 @@ def _askYesNo(question=None): message.write(askString) message.seek(0) - raw = raw_input(message.read()) + raw = input(message.read()) if not len(raw): continue diff --git a/tests/installer/test_drones.py b/tests/installer/test_drones.py index 5251027db..2244dcb12 100644 --- a/tests/installer/test_drones.py +++ b/tests/installer/test_drones.py @@ -17,6 +17,7 @@ import os import shutil +import tarfile import tempfile from unittest import TestCase