From 79c3a1b255e565efd69471a17f489b1b3075cc0d Mon Sep 17 00:00:00 2001 From: Sun Austin Date: Tue, 18 Dec 2018 13:32:08 +0800 Subject: [PATCH] Fix: "import" issue for Python 2/3 compatible code use proper absolute path to import modules remove ignore case 'H301: one import per line' Story: 2002909 Task: 24886 Change-Id: I1d72e68ead64492ff0c74f8c1bf1b460b573bc1e Signed-off-by: Sun Austin --- .../ceph-manager/ceph_manager/ceph.py | 4 ++-- .../ceph-manager/ceph_manager/constants.py | 2 +- .../ceph-manager/ceph_manager/exception.py | 3 ++- .../ceph-manager/ceph_manager/monitor.py | 9 ++++++--- .../ceph-manager/ceph_manager/server.py | 9 +++++---- logging/logmgmt/logmgmt/logmgmt/logmgmt.py | 3 ++- .../hostdata-collectors/scripts/live_stream.py | 6 ++++-- tox.ini | 3 +-- .../platform_util/license/license.py | 15 ++++++++++++--- 9 files changed, 35 insertions(+), 19 deletions(-) diff --git a/ceph/ceph-manager/ceph-manager/ceph_manager/ceph.py b/ceph/ceph-manager/ceph-manager/ceph_manager/ceph.py index a143b5775..50e159931 100644 --- a/ceph/ceph-manager/ceph-manager/ceph_manager/ceph.py +++ b/ceph/ceph-manager/ceph-manager/ceph_manager/ceph.py @@ -4,8 +4,8 @@ # SPDX-License-Identifier: Apache-2.0 # -import exception -from i18n import _LI +from ceph_manager import exception +from ceph_manager.i18n import _LI # noinspection PyUnresolvedReferences from oslo_log import log as logging diff --git a/ceph/ceph-manager/ceph-manager/ceph_manager/constants.py b/ceph/ceph-manager/ceph-manager/ceph_manager/constants.py index 6cfbba4f8..359a7381e 100644 --- a/ceph/ceph-manager/ceph-manager/ceph_manager/constants.py +++ b/ceph/ceph-manager/ceph-manager/ceph_manager/constants.py @@ -4,7 +4,7 @@ # SPDX-License-Identifier: Apache-2.0 # -from i18n import _ +from ceph_manager.i18n import _ # noinspection PyUnresolvedReferences from sysinv.common import constants as sysinv_constants diff --git a/ceph/ceph-manager/ceph-manager/ceph_manager/exception.py b/ceph/ceph-manager/ceph-manager/ceph_manager/exception.py index 978fe752a..a098a1dd8 100644 --- a/ceph/ceph-manager/ceph-manager/ceph_manager/exception.py +++ b/ceph/ceph-manager/ceph-manager/ceph_manager/exception.py @@ -5,7 +5,8 @@ # # noinspection PyUnresolvedReferences -from i18n import _, _LW +from ceph_manager.i18n import _ +from ceph_manager.i18n import _LW # noinspection PyUnresolvedReferences from oslo_log import log as logging diff --git a/ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py b/ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py index 2a13f88a1..364ac96db 100644 --- a/ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py +++ b/ceph/ceph-manager/ceph-manager/ceph_manager/monitor.py @@ -14,10 +14,13 @@ from fm_api import constants as fm_constants from oslo_log import log as logging # noinspection PyProtectedMember -from i18n import _, _LI, _LW, _LE +from ceph_manager.i18n import _ +from ceph_manager.i18n import _LI +from ceph_manager.i18n import _LW +from ceph_manager.i18n import _LE -import constants -import exception +from ceph_manager import constants +from ceph_manager import exception LOG = logging.getLogger(__name__) diff --git a/ceph/ceph-manager/ceph-manager/ceph_manager/server.py b/ceph/ceph-manager/ceph-manager/ceph_manager/server.py index 72edf406b..18f21243b 100644 --- a/ceph/ceph-manager/ceph-manager/ceph_manager/server.py +++ b/ceph/ceph-manager/ceph-manager/ceph_manager/server.py @@ -30,11 +30,12 @@ from oslo_service import loopingcall # noinspection PyUnresolvedReferences from cephclient import wrapper -from monitor import Monitor -import exception -import constants +from ceph_manager.monitor import Monitor +from ceph_manager import exception +from ceph_manager import constants -from i18n import _LI, _LW +from ceph_manager.i18n import _LI +from ceph_manager.i18n import _LW from retrying import retry eventlet.monkey_patch(all=True) diff --git a/logging/logmgmt/logmgmt/logmgmt/logmgmt.py b/logging/logmgmt/logmgmt/logmgmt/logmgmt.py index c8d787c8c..6db2e05fe 100644 --- a/logging/logmgmt/logmgmt/logmgmt/logmgmt.py +++ b/logging/logmgmt/logmgmt/logmgmt/logmgmt.py @@ -8,6 +8,7 @@ SPDX-License-Identifier: Apache-2.0 ################### # IMPORTS ################### +from __future__ import absolute_import import logging import logging.handlers import time @@ -19,7 +20,7 @@ import sys from daemon import runner -import prepostrotate +from logmgmt import prepostrotate ################### # CONSTANTS diff --git a/tools/engtools/hostdata-collectors/scripts/live_stream.py b/tools/engtools/hostdata-collectors/scripts/live_stream.py index 7f7cbb054..05244e74b 100644 --- a/tools/engtools/hostdata-collectors/scripts/live_stream.py +++ b/tools/engtools/hostdata-collectors/scripts/live_stream.py @@ -16,8 +16,10 @@ import logging from six.moves import configparser import itertools import six -from multiprocessing import Process, cpu_count -from subprocess import Popen, PIPE +from multiprocessing import Process +from multiprocessing import cpu_count +from subprocess import Popen +from subprocess import PIPE from collections import OrderedDict from six.moves import input diff --git a/tox.ini b/tox.ini index 93d5ae17a..9c5db307d 100644 --- a/tox.ini +++ b/tox.ini @@ -74,7 +74,6 @@ commands = # H233: Python 3.x incompatible use of print operator # H237: module exception is removed in Python 3 # H238: old style class declaration, use new style -# H301: one import per line # H306: imports not in alphabetical order # H401: docstring should not start with a space # H404: multi line docstring should start without a leading new line @@ -94,7 +93,7 @@ commands = # F841 local variable '_alarm_state' is assigned to but never used ignore = E101,E121,E123,E124,E125,E126,E127,E128,E201,E202,E203,E211,E221,E222,E225,E226,E231,E251,E261,E265,E266, E302,E303,E305,E402,E501,E711,E722,E741,E999, - H101,H102,H104,H201,H238,H233,H237,H301,H306,H401,H404,H405, + H101,H102,H104,H201,H238,H233,H237,H306,H401,H404,H405, W191,W291,W391,W503, B001,B007,B301,B306, F401,F841 diff --git a/utilities/platform-util/platform-util/platform_util/license/license.py b/utilities/platform-util/platform-util/platform_util/license/license.py index 479ce0a01..4cb4aca57 100644 --- a/utilities/platform-util/platform-util/platform_util/license/license.py +++ b/utilities/platform-util/platform-util/platform_util/license/license.py @@ -3,14 +3,23 @@ # # SPDX-License-Identifier: Apache-2.0 # -from ctypes import cdll,util,c_bool,c_int,c_char_p,pointer,create_string_buffer +from ctypes import cdll +from ctypes import util +from ctypes import c_bool +from ctypes import c_int +from ctypes import c_char_p +from ctypes import pointer +from ctypes import create_string_buffer import logging import os -from platform_util.license import constants,exception +from platform_util.license import constants +from platform_util.license import exception import re import sys from sysinv.common import constants as sysinv_constants -from tsconfig.tsconfig import system_type,system_mode, SW_VERSION +from tsconfig.tsconfig import system_type +from tsconfig.tsconfig import system_mode +from tsconfig.tsconfig import SW_VERSION LOG = logging.getLogger(__name__)