From 6dabd5cd9e39649a67921d773bbfe0138403c2ec Mon Sep 17 00:00:00 2001 From: Trinh Nguyen Date: Mon, 28 Jan 2019 17:19:07 +0900 Subject: [PATCH] Update hacking and fix pep8 Change-Id: I6dbe75895d33f80faf8fa56bf6d342dcaf81e587 Signed-off-by: Trinh Nguyen Co-Authored-By: ZhijunWei --- api-ref/source/conf.py | 3 ++- lower-constraints.txt | 2 +- searchlight/cmd/api.py | 26 +++++++++---------- searchlight/cmd/control.py | 15 +++++------ searchlight/i18n.py | 4 ++- .../tests/functional/generate_load_data.py | 12 ++++----- test-requirements.txt | 3 ++- tools/install_venv_common.py | 6 ++--- 8 files changed, 35 insertions(+), 36 deletions(-) diff --git a/api-ref/source/conf.py b/api-ref/source/conf.py index 1235183f..ecf27b90 100644 --- a/api-ref/source/conf.py +++ b/api-ref/source/conf.py @@ -32,6 +32,8 @@ import warnings import openstackdocstheme +from searchlight.version import version_info + html_theme = 'openstackdocs' html_theme_path = [openstackdocstheme.get_html_theme_path()] html_theme_options = { @@ -72,7 +74,6 @@ copyright = u'2015-present, OpenStack Foundation' # |version| and |release|, also used in various other places throughout the # built documents. # -from searchlight.version import version_info # The full version, including alpha/beta/rc tags. release = version_info.release_string() # The short X.Y version. diff --git a/lower-constraints.txt b/lower-constraints.txt index 0f3325be..128db410 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -27,7 +27,7 @@ fixtures==3.0.0 flake8==2.2.4 futurist==1.6.0 greenlet==0.4.10 -hacking==0.10.0 +hacking==1.1.0 httplib2==0.12.0 idna==2.6 imagesize==1.0.0 diff --git a/searchlight/cmd/api.py b/searchlight/cmd/api.py index c0bc8d4a..a3d60f52 100755 --- a/searchlight/cmd/api.py +++ b/searchlight/cmd/api.py @@ -21,13 +21,24 @@ Searchlight API Server """ +import eventlet import os import sys -import eventlet +from oslo_config import cfg +from oslo_log import log as logging from oslo_reports import guru_meditation_report as gmr from oslo_utils import encodeutils +import osprofiler.notifier +import osprofiler.web +from searchlight.common import config +from searchlight.common import exception +from searchlight.common import utils +from searchlight.common import wsgi +from searchlight import notifier +from searchlight import service_policies +from searchlight import version # Monkey patch socket, time, select, threads # NOTE(sjmc7): to workaround issue with 2.7.12-1ubuntu0~16.04.3 and @@ -46,19 +57,6 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'searchlight', '__init__.py')): sys.path.insert(0, possible_topdir) -from oslo_config import cfg -from oslo_log import log as logging -import osprofiler.notifier -import osprofiler.web - -from searchlight.common import config -from searchlight.common import exception -from searchlight.common import utils -from searchlight.common import wsgi -from searchlight import notifier -from searchlight import service_policies -from searchlight import version - CONF = cfg.CONF CONF.import_group("profiler", "searchlight.common.wsgi") CONF.import_group("api", "searchlight.common.wsgi") diff --git a/searchlight/cmd/control.py b/searchlight/cmd/control.py index 4b88e249..e621dc15 100644 --- a/searchlight/cmd/control.py +++ b/searchlight/cmd/control.py @@ -31,6 +31,13 @@ import sys import tempfile import time +from oslo_config import cfg +from oslo_utils import units +from six.moves import range + +from searchlight.common import config +from searchlight.i18n import _ + # If ../searchlight/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -39,14 +46,6 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'searchlight', '__init__.py')): sys.path.insert(0, possible_topdir) -from oslo_config import cfg -from oslo_utils import units -# NOTE(jokke): simplified transition to py3, behaves like py2 xrange -from six.moves import range - -from searchlight.common import config -from searchlight.i18n import _ - CONF = cfg.CONF ALL_COMMANDS = ['start', 'status', 'stop', 'shutdown', 'restart', diff --git a/searchlight/i18n.py b/searchlight/i18n.py index 7875a4d4..493284b6 100644 --- a/searchlight/i18n.py +++ b/searchlight/i18n.py @@ -13,7 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_i18n import * # noqa +from oslo_i18n import get_available_languages # noqa +from oslo_i18n import translate # noqa +from oslo_i18n import TranslatorFactory # noqa _translators = TranslatorFactory(domain='searchlight') diff --git a/searchlight/tests/functional/generate_load_data.py b/searchlight/tests/functional/generate_load_data.py index d4e3fb75..80fd8922 100644 --- a/searchlight/tests/functional/generate_load_data.py +++ b/searchlight/tests/functional/generate_load_data.py @@ -14,9 +14,13 @@ # limitations under the License. import os - import simplejson as json +from glanceclient.v2 import client as glance +from keystoneauth1 import session +from keystoneclient.auth.identity import v2 +import novaclient.client + IMAGES_FILE = "searchlight/tests/functional/data/load/images.json" METADEFS_FILE = "searchlight/tests/functional/data/load/metadefs.json" IMAGE_MEMBERS_FILE = \ @@ -26,12 +30,6 @@ FLAVORS_FILE = "searchlight/tests/functional/data/load/flavors.json" SERVER_GROUP_FILE = \ "searchlight/tests/functional/data/load/server_groups.json" - -from glanceclient.v2 import client as glance -from keystoneauth1 import session -from keystoneclient.auth.identity import v2 -import novaclient.client - _session = None diff --git a/test-requirements.txt b/test-requirements.txt index 9494a95d..1e4a403c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -3,7 +3,8 @@ # process, which may cause wedges in the gate later. # Hacking already pins down pep8, pyflakes and flake8 -hacking<0.11,>=0.10.0 +#hacking<0.11,>=0.10.0 +hacking>=1.1.0,<1.2.0 # Apache-2.0 # For translations processing Babel!=2.4.0,>=2.3.4 # BSD diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py index 53b8eb25..c052b3ce 100644 --- a/tools/install_venv_common.py +++ b/tools/install_venv_common.py @@ -117,9 +117,9 @@ class InstallVenv(object): self.pip_install('setuptools') self.pip_install('pbr') upper_constraints = ( - os.environ.get("UPPER_CONSTRAINTS_FILE") - or ("https://git.openstack.org/cgit/openstack/requirements" - "/plain/upper-constraints.txt")) + os.environ.get("UPPER_CONSTRAINTS_FILE") or + ("https://git.openstack.org/cgit/openstack/requirements" + "/plain/upper-constraints.txt")) self.pip_install('-c', upper_constraints, '-r', self.requirements, '-r', self.test_requirements)