basestring replaced with six.string_types

That's needed to move further in py3 compatibility.

Partially-Implements: blueprint ceilometer-py33-support
Change-Id: I5796de3b3f359c95ddc059374e19f7e7154e45c6
This commit is contained in:
Dina Belova 2014-07-25 14:42:40 +04:00
parent a77dd2b540
commit 53e442a8b4
5 changed files with 10 additions and 5 deletions

View File

@ -661,7 +661,7 @@ class OldSample(_Base):
counter_volume = float(counter_volume)
resource_metadata = _flatten_metadata(resource_metadata)
# this is to make it easier for clients to pass a timestamp in
if timestamp and isinstance(timestamp, basestring):
if timestamp and isinstance(timestamp, six.string_types):
timestamp = timeutils.parse_isotime(timestamp)
super(OldSample, self).__init__(counter_volume=counter_volume,

View File

@ -16,6 +16,7 @@
# under the License.
from oslo.config import cfg
import six
OPTS = [
@ -36,7 +37,7 @@ def add_reserved_user_metadata(src_metadata, dest_metadata):
for prefix in cfg.CONF.reserved_metadata_namespace:
md = dict(
(k[len(prefix):].replace('.', '_'),
v[:limit] if isinstance(v, basestring) else v)
v[:limit] if isinstance(v, six.string_types) else v)
for k, v in src_metadata.items()
if (k.startswith(prefix) and
k[len(prefix):].replace('.', '_') not in dest_metadata)

View File

@ -15,6 +15,7 @@
# under the License.
import json
import six
from sqlalchemy import Boolean
from sqlalchemy import Column
from sqlalchemy import Float
@ -55,7 +56,7 @@ def upgrade(migrate_engine):
rmeta = json.loads(row['resource_metadata'])
for key, v in utils.dict_to_keyval(rmeta):
ins = None
if isinstance(v, basestring) or v is None:
if isinstance(v, six.string_types) or v is None:
ins = meta_tables['metadata_text'].insert()
elif isinstance(v, bool):
ins = meta_tables['metadata_bool'].insert()

View File

@ -19,6 +19,7 @@ import uuid
from ceilometerclient.v2 import alarms
import eventlet
import six
from ceilometer.alarm import rpc as rpc_alarm
from ceilometer.alarm.storage import models
@ -122,7 +123,7 @@ class TestRPCAlarmNotifier(tests_base.BaseTestCase):
self.notifier.notify(self.alarms[0], 'ok', 42, {})
self.notifier_server.rpc.wait()
reason = self.notifier_server.notified[0]['reason']
self.assertIsInstance(reason, basestring)
self.assertIsInstance(reason, six.string_types)
def test_notify_no_actions(self):
alarm = alarms.Alarm(None, info={

View File

@ -17,6 +17,8 @@
import re
import six
from ceilometer.openstack.common.gettextutils import _
from ceilometer.openstack.common import log
from ceilometer.openstack.common import timeutils
@ -56,7 +58,7 @@ class ScalingTransformer(transformer.TransformerBase):
ns = transformer.Namespace(s.as_dict())
scale = self.scale
return ((eval(scale, {}, ns) if isinstance(scale, basestring)
return ((eval(scale, {}, ns) if isinstance(scale, six.string_types)
else s.volume * scale) if scale else s.volume)
def _map(self, s, attr):