Remove six.text_type/b/u
Replace the following items with Python 3 style code. - six.text_type - six.b - six.u Like Any(str, six.text_type), currently only keep Any(str). Change-Id: I735e8a8a670659123e533091916fd3bbedabb95e
This commit is contained in:
parent
38da3437ed
commit
9ec5f4de5f
@ -111,7 +111,6 @@ rfc3986==1.1.0
|
||||
Routes==2.4.1
|
||||
setproctitle==1.1.10
|
||||
simplejson==3.13.2
|
||||
six==1.11.0
|
||||
SQLAlchemy==1.2.5
|
||||
sqlalchemy-migrate==0.11.0
|
||||
sqlparse==0.2.4
|
||||
|
@ -36,7 +36,6 @@ PyYAML>=3.13 # MIT
|
||||
requests>=2.18.4 # Apache-2.0
|
||||
WebOb>=1.7.4 # MIT
|
||||
eventlet!=0.20.1,>=0.20.0 # MIT
|
||||
six>=1.11.0 # MIT
|
||||
debtcollector>=1.19.0 # Apache-2.0
|
||||
cotyledon>=1.6.8 # Apache-2.0
|
||||
pytz>=2018.3 # MIT
|
||||
|
2
tox.ini
2
tox.ini
@ -1,6 +1,6 @@
|
||||
[tox]
|
||||
minversion = 3.1.1
|
||||
envlist = py37,pep8
|
||||
envlist = py38,pep8
|
||||
skipsdist = True
|
||||
ignore_basepython_conflict = True
|
||||
|
||||
|
@ -16,7 +16,6 @@ import os
|
||||
import psutil
|
||||
import socket
|
||||
|
||||
import six
|
||||
import tenacity
|
||||
import tooz.coordination
|
||||
|
||||
@ -35,7 +34,8 @@ class Coordinator(object):
|
||||
self.coordinator = None
|
||||
if self.backend_url:
|
||||
self.coordinator = tooz.coordination.get_coordinator(
|
||||
self.backend_url, six.b('%s_%s' % (my_id, os.getpid())))
|
||||
self.backend_url,
|
||||
'{}_{}'.format(my_id, os.getpid()).encode("latin-1"))
|
||||
|
||||
def start(self):
|
||||
if self.backend_url:
|
||||
@ -73,8 +73,9 @@ class Coordinator(object):
|
||||
'created': isoformat
|
||||
}
|
||||
)
|
||||
join_req = self.coordinator.join_group(six.b(group_id),
|
||||
six.b(capabilities))
|
||||
join_req = self.coordinator.join_group(
|
||||
group_id.encode("latin-1"),
|
||||
capabilities.encode("latin-1"))
|
||||
join_req.get()
|
||||
|
||||
LOG.info('Joined service group:%s, member:%s',
|
||||
@ -84,7 +85,8 @@ class Coordinator(object):
|
||||
except tooz.coordination.MemberAlreadyExist:
|
||||
return
|
||||
except tooz.coordination.GroupNotCreated as e:
|
||||
create_grp_req = self.coordinator.create_group(six.b(group_id))
|
||||
create_grp_req = self.coordinator.create_group(
|
||||
group_id.encode("latin-1"))
|
||||
|
||||
try:
|
||||
create_grp_req.get()
|
||||
@ -96,7 +98,7 @@ class Coordinator(object):
|
||||
|
||||
def leave_group(self, group_id):
|
||||
if self.is_active():
|
||||
self.coordinator.leave_group(six.b(group_id))
|
||||
self.coordinator.leave_group(group_id.encode("latin-1"))
|
||||
LOG.info('Left group %s', group_id)
|
||||
|
||||
def get_services(self, group_id='vitrage'):
|
||||
@ -104,11 +106,13 @@ class Coordinator(object):
|
||||
return []
|
||||
|
||||
while True:
|
||||
get_members_req = self.coordinator.get_members(six.b(group_id))
|
||||
get_members_req = self.coordinator.get_members(
|
||||
group_id.encode("latin-1"))
|
||||
try:
|
||||
return [json.loads(
|
||||
self.coordinator.get_member_capabilities(
|
||||
six.b(group_id), member).get().decode('us-ascii'))
|
||||
group_id.encode("latin-1"),
|
||||
member).get().decode('us-ascii'))
|
||||
for member in get_members_req.get()]
|
||||
except tooz.coordination.GroupNotCreated:
|
||||
self.join_group(group_id)
|
||||
|
@ -12,7 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import json
|
||||
import six
|
||||
|
||||
from oslo_log import log
|
||||
|
||||
@ -357,7 +356,7 @@ def _parse_query(data, key):
|
||||
|
||||
query_fields = data.get(AodhProps.QUERY, {})
|
||||
try:
|
||||
if isinstance(query_fields, six.text_type):
|
||||
if isinstance(query_fields, str):
|
||||
query_fields = json.loads(query_fields)
|
||||
if not isinstance(query_fields, list):
|
||||
query_fields = [query_fields]
|
||||
|
@ -19,7 +19,6 @@ Collectd plugin for sending notifications to vitrage
|
||||
|
||||
import collectd
|
||||
import hashlib
|
||||
import six
|
||||
from vitrage.datasources.collectd import COLLECTD_DATASOURCE
|
||||
|
||||
from vitrage.datasources.collectd.collectd_vitrage.plugin import CollectDPlugin
|
||||
@ -103,7 +102,7 @@ class VitrageNotifier(CollectDPlugin):
|
||||
resources = [notification.host, notification.plugin_instance,
|
||||
notification.type_instance, notification.type]
|
||||
alarm_id = ''.join([resource for resource in resources if resource])
|
||||
alarm_uuid = hashlib.md5(six.b(alarm_id)).hexdigest()
|
||||
alarm_uuid = hashlib.md5(alarm_id.encode("latin-1")).hexdigest()
|
||||
return alarm_uuid
|
||||
|
||||
|
||||
|
@ -19,7 +19,6 @@ from ipaddress import ip_address
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
import requests
|
||||
import six
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from vitrage.common.constants import DatasourceAction
|
||||
@ -412,10 +411,10 @@ class PrometheusDriver(AlarmDriverBase):
|
||||
"""
|
||||
# check if the value is ip
|
||||
try:
|
||||
ip = ip_address(six.u(value))
|
||||
ip = ip_address(str(value))
|
||||
except ValueError:
|
||||
parsed = urlparse.urlparse('//{}'.format(value))
|
||||
ip = ip_address(six.u(parsed.hostname))
|
||||
ip = ip_address(str(parsed.hostname))
|
||||
return ip
|
||||
|
||||
@staticmethod
|
||||
|
@ -12,7 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import re
|
||||
import six
|
||||
|
||||
from oslo_log import log
|
||||
from voluptuous import All
|
||||
@ -95,7 +94,7 @@ def _validate_def_template_template_sections(def_template_conf):
|
||||
|
||||
|
||||
def _validate_template_sections(template_conf):
|
||||
any_str = Any(str, six.text_type)
|
||||
any_str = Any(str)
|
||||
paramsSchema = Schema({
|
||||
any_str: Any(any_str, Schema({
|
||||
Optional(TemplateFields.DESCRIPTION): any_str,
|
||||
@ -123,7 +122,7 @@ def _validate_template_sections(template_conf):
|
||||
|
||||
|
||||
def _validate_metadata_section(metadata):
|
||||
any_str = Any(str, six.text_type)
|
||||
any_str = Any(str)
|
||||
|
||||
schema = Schema({
|
||||
TemplateFields.VERSION: any_str,
|
||||
@ -135,7 +134,7 @@ def _validate_metadata_section(metadata):
|
||||
|
||||
|
||||
def _validate_includes_section(includes):
|
||||
any_str = Any(str, six.text_type)
|
||||
any_str = Any(str)
|
||||
if not includes:
|
||||
LOG.error('%s status code: %s' % (status_msgs[140], 140))
|
||||
return get_fault_result(RESULT_DESCRIPTION, 140)
|
||||
@ -219,7 +218,7 @@ def _validate_entities(entities, has_includes):
|
||||
|
||||
|
||||
def _validate_entity_dict(entity_dict):
|
||||
any_str = Any(str, six.text_type)
|
||||
any_str = Any(str)
|
||||
schema = Schema({
|
||||
Required(TemplateFields.CATEGORY, msg=42):
|
||||
All(_validate_category_field()),
|
||||
@ -249,7 +248,7 @@ def _validate_relationships(relationships):
|
||||
|
||||
|
||||
def _validate_relationship_dict(relationship_dict):
|
||||
any_str = Any(str, six.text_type)
|
||||
any_str = Any(str)
|
||||
schema = Schema({
|
||||
Required(TemplateFields.SOURCE, msg=102): any_str,
|
||||
Required(TemplateFields.TARGET, msg=103): any_str,
|
||||
@ -282,7 +281,7 @@ def _validate_scenarios_section(scenarios):
|
||||
|
||||
|
||||
def _validate_scenario(scenario):
|
||||
any_str = Any(str, six.text_type)
|
||||
any_str = Any(str)
|
||||
schema = Schema({
|
||||
Required(TemplateFields.CONDITION, msg=83): any_str,
|
||||
Required(TemplateFields.ACTIONS, msg=84): list
|
||||
|
@ -12,7 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import re
|
||||
import six
|
||||
|
||||
from oslo_log import log
|
||||
from voluptuous import Any
|
||||
@ -33,7 +32,7 @@ from vitrage.evaluator.template_schema_factory import TemplateSchemaFactory
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
any_str = Any(str, six.text_type)
|
||||
any_str = Any(str)
|
||||
|
||||
|
||||
class SyntaxValidator(object):
|
||||
|
Loading…
x
Reference in New Issue
Block a user