Masakari模块
1、更新Py文件头部声明
#!/usr/bin/python
改为
#!/usr/bin/python3
2、移除six模块
from six.moves import http_client as http
改为
from http import client as http
429: "overLimit"
改为
http.TOO_MANY_REQUESTS: "overLimit"
six.text_type
改为
str
import six.moves.urllib.parse as urlparse
改为
from urllib import parse as urlparse
@six.add_metaclass(abc.ABCMeta)
class V1APIExtensionBase(object):
改为
class V1APIExtensionBase(object, metaclass=abc.ABCMeta):
if six.PY3:
response.headers['Content-Length'] = (str(
response.headers['Content-Length']))
else:
# NOTE: we need to encode 'Content-Length' header, since
# webob.Response auto sets it if "body" attr is presented.
# github.com/Pylons/webob/blob/1.5.0b0/webob/response.py#L147
response.headers['Content-Length'] = utils.utf8(
response.headers['Content-Length'])
改为
response.headers['Content-Length'] = (str(
response.headers['Content-Length']))
import six
if six.PY2: # noqa
import urllib2
else: # noqa
from urllib import request as urllib2
urllib2.parse_http_list(value)
改为
from urllib import request
request.parse_http_list(value)
six.unichr(i)
改为
chr(i)
six.binary_type
改为
bytes
six.reraise(*e.exc_info)
改为
def reraise(tp, value, tb=None):
try:
if value is None:
value = tp()
if value.__traceback__ is not tb:
raise value.with_traceback(tb)
raise value
finally:
value = None
tb = None
reraise(*e.exc_info)
@six.wraps(f)
改为
@functools.wraps(f)
six.reraise(type(desired_exc), desired_exc, sys.exc_info()[2])
改为
from masakari import utils
utils.reraise(type(desired_exc), desired_exc, sys.exc_info()[2])
from six.moves import configparser
改为
import configparser
##Masakri-monitor模块
1、移除six模块
import six
@six.add_metaclass(abc.ABCMeta)
class DriverBase(object):
改为
class DriverBase(object, metaclass=abc.ABCMeta):
@six.wraps(f)
改为
import functools
@functools.wraps(f)
from six.moves import configparser
改为
import configparser
if six.PY2:
is_method = inspect.ismethod
else:
def is_method(obj):
# Unbound methods became regular functions on Python 3
return inspect.ismethod(obj) or inspect.isfunction(obj)
改为
def is_method(obj):
return inspect.ismethod(obj) or inspect.isfunction(obj)