From b008ef902d7a03e9d0c5c6829dc4caefd0d663eb Mon Sep 17 00:00:00 2001 From: Cai Hui Date: Wed, 7 Nov 2018 03:39:20 -0500 Subject: [PATCH] Update tox.ini and fix pep8 errors 1.Add [testenv:lower-constraints] 2.Add lower-constraints.txt 3.Check env:UPPER_CONSTRAINTS_FILE 4.Remove passenv parameters which are not required 5.Fix pep8 errors Change-Id: I8ec8aac38e80a6e2b8ce9e9dc70f0cf187c0ce7c --- freezer_dr/common/yaml_parser.py | 2 +- freezer_dr/evacuators/common/manager.py | 4 +- freezer_dr/evacuators/common/utils.py | 3 +- .../evacuators/drivers/default/standard.py | 5 +- freezer_dr/fencers/drivers/ipmi/driver.py | 2 +- freezer_dr/fencers/drivers/ipmi/ipmitool.py | 6 +- freezer_dr/fencers/drivers/libvirt/driver.py | 2 +- freezer_dr/main.py | 7 +- freezer_dr/monitors/drivers/default/driver.py | 9 +- freezer_dr/notifiers/common/driver.py | 2 +- .../drivers/default/default_email.py | 14 +- freezer_dr/notifiers/drivers/slack/slack.py | 9 +- lower-constraints.txt | 124 ++++++++++++++++++ requirements.txt | 16 +-- test-requirements.txt | 11 +- tox.ini | 18 ++- 16 files changed, 184 insertions(+), 50 deletions(-) create mode 100644 lower-constraints.txt diff --git a/freezer_dr/common/yaml_parser.py b/freezer_dr/common/yaml_parser.py index 8db4d97..9a42b98 100644 --- a/freezer_dr/common/yaml_parser.py +++ b/freezer_dr/common/yaml_parser.py @@ -11,8 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import yaml import os +import yaml class YamlParser(object): diff --git a/freezer_dr/evacuators/common/manager.py b/freezer_dr/evacuators/common/manager.py index 9f19174..880ccda 100644 --- a/freezer_dr/evacuators/common/manager.py +++ b/freezer_dr/evacuators/common/manager.py @@ -11,12 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from freezer_dr.evacuators.common.utils import get_nodes_details +from freezer_dr.fencers.common.manager import FencerManager from oslo_config import cfg from oslo_log import log from oslo_utils import importutils -from freezer_dr.fencers.common.manager import FencerManager from time import sleep -from freezer_dr.evacuators.common.utils import get_nodes_details CONF = cfg.CONF LOG = log.getLogger(__name__) diff --git a/freezer_dr/evacuators/common/utils.py b/freezer_dr/evacuators/common/utils.py index d85f464..a514b7c 100644 --- a/freezer_dr/evacuators/common/utils.py +++ b/freezer_dr/evacuators/common/utils.py @@ -11,7 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from freezer_dr.common.utils import get_os_client, get_admin_os_client +from freezer_dr.common.utils import get_admin_os_client +from freezer_dr.common.utils import get_os_client def get_nodes_details(nodes): diff --git a/freezer_dr/evacuators/drivers/default/standard.py b/freezer_dr/evacuators/drivers/default/standard.py index fbf10ec..885e20f 100644 --- a/freezer_dr/evacuators/drivers/default/standard.py +++ b/freezer_dr/evacuators/drivers/default/standard.py @@ -11,11 +11,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +from freezer_dr.common.utils import get_os_client +from freezer_dr.evacuators.common.driver import EvacuatorBaseDriver from oslo_config import cfg from oslo_log import log -from freezer_dr.evacuators.common.driver import EvacuatorBaseDriver -from freezer_dr.common.utils import get_os_client import time + CONF = cfg.CONF LOG = log.getLogger(__name__) diff --git a/freezer_dr/fencers/drivers/ipmi/driver.py b/freezer_dr/fencers/drivers/ipmi/driver.py index 303b16e..3229395 100644 --- a/freezer_dr/fencers/drivers/ipmi/driver.py +++ b/freezer_dr/fencers/drivers/ipmi/driver.py @@ -15,8 +15,8 @@ from freezer_dr.common.yaml_parser import YamlParser from freezer_dr.fencers.common.driver import FencerBaseDriver from freezer_dr.fencers.drivers.ipmi.ipmitool import IpmiInterface -from oslo_log import log from oslo_config import cfg +from oslo_log import log import time CONF = cfg.CONF diff --git a/freezer_dr/fencers/drivers/ipmi/ipmitool.py b/freezer_dr/fencers/drivers/ipmi/ipmitool.py index 0be2b3c..8533765 100644 --- a/freezer_dr/fencers/drivers/ipmi/ipmitool.py +++ b/freezer_dr/fencers/drivers/ipmi/ipmitool.py @@ -12,11 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import sys -import subprocess from distutils import spawn from oslo_log import log +import subprocess +import sys + + LOG = log.getLogger(__name__) diff --git a/freezer_dr/fencers/drivers/libvirt/driver.py b/freezer_dr/fencers/drivers/libvirt/driver.py index f370993..2749357 100644 --- a/freezer_dr/fencers/drivers/libvirt/driver.py +++ b/freezer_dr/fencers/drivers/libvirt/driver.py @@ -14,8 +14,8 @@ from freezer_dr.common.yaml_parser import YamlParser from freezer_dr.fencers.common.driver import FencerBaseDriver import libvirt -from oslo_log import log from oslo_config import cfg +from oslo_log import log import time CONF = cfg.CONF diff --git a/freezer_dr/main.py b/freezer_dr/main.py index cc73db9..278c8ca 100644 --- a/freezer_dr/main.py +++ b/freezer_dr/main.py @@ -15,11 +15,12 @@ from __future__ import print_function from freezer_dr.common import config +from freezer_dr.evacuators.common.manager import EvacuationManager +from freezer_dr.monitors.common.manager import MonitorManager +from freezer_dr.notifiers.common.manager import NotificationManager from oslo_config import cfg from oslo_log import log -from freezer_dr.monitors.common.manager import MonitorManager -from freezer_dr.evacuators.common.manager import EvacuationManager -from freezer_dr.notifiers.common.manager import NotificationManager + CONF = cfg.CONF LOG = log.getLogger(__name__) diff --git a/freezer_dr/monitors/drivers/default/driver.py b/freezer_dr/monitors/drivers/default/driver.py index c420b1f..aeaa135 100644 --- a/freezer_dr/monitors/drivers/default/driver.py +++ b/freezer_dr/monitors/drivers/default/driver.py @@ -13,12 +13,15 @@ # limitations under the License. from freezer_dr.common.osclient import OSClient from freezer_dr.monitors.common.driver import MonitorBaseDriver -from time import sleep -from oslo_config import cfg -from oslo_log import log + from httplib import HTTPConnection from httplib import HTTPSConnection from httplib import socket + +from oslo_config import cfg +from oslo_log import log +from time import sleep + from urlparse import urlparse CONF = cfg.CONF diff --git a/freezer_dr/notifiers/common/driver.py b/freezer_dr/notifiers/common/driver.py index e2ca72f..b919a95 100644 --- a/freezer_dr/notifiers/common/driver.py +++ b/freezer_dr/notifiers/common/driver.py @@ -11,8 +11,8 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -import six import abc +import six @six.add_metaclass(abc.ABCMeta) diff --git a/freezer_dr/notifiers/drivers/default/default_email.py b/freezer_dr/notifiers/drivers/default/default_email.py index aa397ed..30854e0 100644 --- a/freezer_dr/notifiers/drivers/default/default_email.py +++ b/freezer_dr/notifiers/drivers/default/default_email.py @@ -11,15 +11,15 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from oslo_config import cfg -from oslo_log import log -from freezer_dr.notifiers.common.driver import NotifierBaseDriver -from freezer_dr.common.utils import load_jinja_templates from datetime import date -import time -import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText +from freezer_dr.common.utils import load_jinja_templates +from freezer_dr.notifiers.common.driver import NotifierBaseDriver +from oslo_config import cfg +from oslo_log import log +import smtplib +import time CONF = cfg.CONF @@ -114,7 +114,7 @@ class StandardEmail(NotifierBaseDriver): cc_list=self.admin_list or [] ) return True - except: + except Exception: return False def __exit__(self, exc_type, exc_val, exc_tb): diff --git a/freezer_dr/notifiers/drivers/slack/slack.py b/freezer_dr/notifiers/drivers/slack/slack.py index ddde83d..a4aa3a0 100644 --- a/freezer_dr/notifiers/drivers/slack/slack.py +++ b/freezer_dr/notifiers/drivers/slack/slack.py @@ -11,18 +11,17 @@ # See the License for the specific language governing permissions and # limitations under the License. -from oslo_log import log -from freezer_dr.notifiers.common.driver import NotifierBaseDriver from datetime import date -from six.moves import urllib -import requests +from freezer_dr.notifiers.common.driver import NotifierBaseDriver import json +from oslo_log import log +import requests +from six.moves import urllib import time LOG = log.getLogger(__name__) - class SlackNotifier(NotifierBaseDriver): MAX_CACHE_SIZE = 100 diff --git a/lower-constraints.txt b/lower-constraints.txt new file mode 100644 index 0000000..354c80d --- /dev/null +++ b/lower-constraints.txt @@ -0,0 +1,124 @@ +alabaster==0.7.10 +appdirs==1.4.3 +APScheduler==3.0.5 +asn1crypto==0.24.0 +astroid==1.3.8 +Babel==2.5.3 +bcrypt==3.1.4 +botocore==1.5.1 +certifi==2018.1.18 +cffi==1.11.5 +chardet==3.0.4 +cliff==2.11.0 +cmd2==0.8.1 +coverage==4.0 +cryptography==2.1 +ddt==1.0.1 +debtcollector==1.19.0 +decorator==4.2.1 +deprecation==2.0 +doc8==0.6.0 +docutils==0.14 +dogpile.cache==0.6.5 +dulwich==0.19.0 +enum-compat==0.0.2 +eventlet==0.20.0 +extras==1.0.0 +fasteners==0.14.1 +fixtures==3.0.0 +flake8==2.5.4 +future==0.16.0 +greenlet==0.4.13 +hacking==0.12.0 +idna==2.6 +imagesize==1.0.0 +iso8601==0.1.12 +Jinja2==2.10 +jmespath==0.9.3 +jsonpatch==1.21 +jsonpointer==2.0 +jsonschema==2.6.0 +keystoneauth1==3.4.0 +linecache2==1.0.0 +logilab-common==1.4.1 +libvirt-python==1.2.5 +MarkupSafe==1.0 +mccabe==0.4.0 +mock==2.0.0 +monotonic==1.4 +msgpack==0.5.6 +munch==2.2.0 +netaddr==0.7.19 +netifaces==0.10.6 +openstackdocstheme==1.18.1 +openstacksdk==0.12.0 +os-brick==2.2.0 +os-client-config==1.29.0 +os-service-types==1.2.0 +os-win==4.0.0 +osc-lib==1.10.0 +oslo.concurrency==3.26.0 +oslo.config==5.2.0 +oslo.context==2.20.0 +oslo.i18n==3.20.0 +oslo.log==3.36.0 +oslo.privsep==1.28.0 +oslo.serialization==2.25.0 +oslo.service==1.24.0 +oslo.utils==3.33.0 +packaging==17.1 +paramiko==2.0.0 +Paste==2.0.3 +PasteDeploy==1.5.2 +pbr==2.0.0 +pep8==1.7.1 +prettytable==0.7.2 +psutil==3.2.2 +pyasn1==0.4.2 +pycparser==2.18 +pyflakes==1.0.0 +Pygments==2.2.0 +pyinotify==0.9.6 +pylint==1.4.5 +pymongo==3.0.2 +PyMySQL==0.7.6 +PyNaCl==1.2.1 +pyOpenSSL==17.5.0 +pyparsing==2.2.0 +pyperclip==1.6.0 +python-dateutil==2.7.0 +python-keystoneclient==3.8.0 +python-monascaclient==1.1.0 +python-neutronclient==6.7.0 +python-novaclient==9.1.0 +python-openstackclient==3.12.0 +python-subunit==1.2.0 +python-swiftclient==3.2.0 +pytz==2018.3 +PyYAML==3.12.0 +reno==2.5.0 +repoze.lru==0.7 +requests==2.18.4 +requestsexceptions==1.4.0 +retrying==1.3.3 +rfc3986==1.1.0 +Routes==2.4.1 +setuptools==21.0.0 +simplejson==3.13.2 +six==1.10.0 +snowballstemmer==1.2.1 +Sphinx==1.6.2 +sphinxcontrib-websupport==1.0.1 +stestr==2.0.0 +stevedore==1.28.0 +tempest==17.1.0 +stestr==2.0.0 +testtools==2.2.0 +traceback2==1.4.0 +tzlocal==1.5.1 +unittest2==1.1.0 +urllib3==1.22 +voluptuous==0.11.1 +warlock==1.3.0 +WebOb==1.7.4 +wrapt==1.10.11 diff --git a/requirements.txt b/requirements.txt index 4c3ec39..ab0f2cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ -pbr!=2.1.0,>=2.0 # Apache-2.0 +pbr>=2.0.0 # Apache-2.0 python-keystoneclient>=3.8.0 # Apache-2.0 python-monascaclient>=1.1.0 # Apache-2.0 -python-neutronclient>=5.1.0 # Apache-2.0 -python-novaclient>=6.0.0 # Apache-2.0 -PyYAML>=3.10.0 # MIT -oslo.config>=3.14.0,!=4.4.0,!=4.3.0 # Apache-2.0 -oslo.utils>=3.18.0 # Apache-2.0 -oslo.log>=3.11.0 # Apache-2.0 +python-neutronclient>=6.7.0 # Apache-2.0 +python-novaclient>=9.1.0 # Apache-2.0 +PyYAML>=3.12.0 # MIT +oslo.config>=5.2.0 # Apache-2.0 +oslo.utils>=3.33.0 # Apache-2.0 +oslo.log>=3.36.0 # Apache-2.0 libvirt-python>=1.2.5 # LGPLv2+ -Jinja2>=2.8 # BSD License (3 clause) +Jinja2>=2.10 # BSD License (3 clause) diff --git a/test-requirements.txt b/test-requirements.txt index a677ca3..e67474c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -4,13 +4,12 @@ astroid==1.6.5 # LGPLv2.1 flake8>=2.5.4,<2.6.0 # MIT hacking>=0.12.0,!=0.13.0,<0.14 # Apache-2.0 -coverage>=3.6 -mock>=1.0 -pep8==1.5.7 -mccabe==0.2.1 # MIT License +coverage>=4.0 +mock>=2.0.0 +mccabe==0.4.0 # MIT License pylint==1.9.2 # GPLv2 -pyflakes==0.8.1 +pyflakes==1.0.0 stestr>=2.0.0 # Apache-2.0 -testtools>=0.9.36 +testtools>=2.2.0 sphinx!=1.6.6,!=1.6.7,>=1.6.2 # BSD openstackdocstheme>=1.18.1 # Apache-2.0 diff --git a/tox.ini b/tox.ini index 822f3e5..5397099 100644 --- a/tox.ini +++ b/tox.ini @@ -7,13 +7,9 @@ usedevelop = True deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt passenv = - FREEZER_TEST_OS_TENANT_NAME - FREEZER_TEST_OS_USERNAME - FREEZER_TEST_OS_REGION_NAME - FREEZER_TEST_OS_PASSWORD - FREEZER_TEST_OS_AUTH_URL http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY -install_command = pip install -U {opts} {packages} + +install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt} {opts} {packages} setenv = VIRTUAL_ENV={envdir} OS_TEST_PATH = ./tests/unit @@ -24,9 +20,10 @@ commands = coverage combine coverage html -d cover coverage xml -o cover/coverage.xml -# coverage report -m + coverage report -m rm -f .coverage rm -rf .testrepository + whitelist_externals = find coverage @@ -78,3 +75,10 @@ ignore = H select = H102, H103, H201, H501, H903, H201, H306, H301, H233 show-source = True exclude = .venv,.tox,dist,doc,test,*egg,tests + +[testenv:lower-constraints] +basepython = python3 +deps = + -c{toxinidir}/lower-constraints.txt + -r{toxinidir}/test-requirements.txt + -r{toxinidir}/requirements.txt