Merge "Update code to pass pep8 under python 3"
This commit is contained in:
commit
f414212d79
|
@ -39,7 +39,7 @@ class DragonflowException(Exception):
|
|||
|
||||
if six.PY2:
|
||||
def __unicode__(self):
|
||||
return unicode(self.msg)
|
||||
return six.text_type(self.msg)
|
||||
|
||||
def __str__(self):
|
||||
return self.msg
|
||||
|
|
|
@ -45,8 +45,8 @@ class RejectRules(ctypes.Structure):
|
|||
self.version_eq_given, self.version_gt_given,
|
||||
self.given_version)
|
||||
|
||||
def __cmp__(self, other):
|
||||
return cmp(self._as_tuple(), other._as_tuple())
|
||||
def __lt__(self, other):
|
||||
return self._as_tuple() < other._as_tuple()
|
||||
|
||||
def __repr__(self):
|
||||
return 'ramcloud.RejectRules(%s)' % str(self._as_tuple())
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
import crc16
|
||||
import six
|
||||
|
||||
RedisClusterHashSlots = 16384
|
||||
|
||||
|
@ -21,7 +22,7 @@ def key2slot(key):
|
|||
|
||||
This also works for binary keys that is used in python 3.
|
||||
"""
|
||||
k = unicode(key)
|
||||
k = six.text_type(key)
|
||||
start = k.find("{")
|
||||
|
||||
if start > -1:
|
||||
|
|
|
@ -82,7 +82,7 @@ def check_dhcp_network_rule(flows, network_key):
|
|||
|
||||
|
||||
def print_command(full_args, run_as_root=False):
|
||||
print ('{}'.format(agent_utils.execute(
|
||||
print('{}'.format(agent_utils.execute(
|
||||
full_args,
|
||||
run_as_root=run_as_root,
|
||||
process_input=None,
|
||||
|
|
|
@ -10,9 +10,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import sys
|
||||
|
||||
from oslo_log import log
|
||||
from oslo_utils import excutils
|
||||
|
||||
from dragonflow.tests.common import app_testing_objects
|
||||
from dragonflow.tests.common import utils as test_utils
|
||||
|
@ -46,12 +45,10 @@ class TestApps(test_base.DFTestBase):
|
|||
['ovsdb-client', 'dump', 'Open_vSwitch'],
|
||||
True
|
||||
)
|
||||
except Exception as e:
|
||||
traceback = sys.exc_info()[2]
|
||||
try:
|
||||
topology.close()
|
||||
except Exception:
|
||||
pass # Ignore
|
||||
# Just calling raise may raise an exception from topology.close()
|
||||
raise e, None, traceback
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
try:
|
||||
topology.close()
|
||||
except Exception:
|
||||
pass # Ignore
|
||||
topology.close()
|
||||
|
|
|
@ -416,13 +416,13 @@ class TestDbTableMonitors(PubSubTestBase):
|
|||
}
|
||||
|
||||
expected_event = {
|
||||
'table': unicode('chassis'),
|
||||
'key': unicode('chassis-1'),
|
||||
'action': unicode('create'),
|
||||
'table': six.text_type('chassis'),
|
||||
'key': six.text_type('chassis-1'),
|
||||
'action': six.text_type('create'),
|
||||
'value': None,
|
||||
}
|
||||
self.assertNotIn(expected_event, self.namespace.events)
|
||||
expected_event['value'] = unicode(jsonutils.dumps(test_chassis))
|
||||
expected_event['value'] = six.text_type(jsonutils.dumps(test_chassis))
|
||||
self.assertNotIn(expected_event, self.namespace.events)
|
||||
self.nb_api.driver.create_key(
|
||||
'chassis',
|
||||
|
@ -435,13 +435,13 @@ class TestDbTableMonitors(PubSubTestBase):
|
|||
|
||||
test_chassis["ip"] = "2.3.4.5"
|
||||
expected_event = {
|
||||
'table': unicode('chassis'),
|
||||
'key': unicode('chassis-1'),
|
||||
'action': unicode('set'),
|
||||
'table': six.text_type('chassis'),
|
||||
'key': six.text_type('chassis-1'),
|
||||
'action': six.text_type('set'),
|
||||
'value': None,
|
||||
}
|
||||
self.assertNotIn(expected_event, self.namespace.events)
|
||||
expected_event['value'] = unicode(jsonutils.dumps(test_chassis))
|
||||
expected_event['value'] = six.text_type(jsonutils.dumps(test_chassis))
|
||||
self.assertNotIn(expected_event, self.namespace.events)
|
||||
self.nb_api.driver.set_key(
|
||||
'chassis',
|
||||
|
@ -453,9 +453,9 @@ class TestDbTableMonitors(PubSubTestBase):
|
|||
self.assertIn(expected_event, self.namespace.events)
|
||||
|
||||
expected_event = {
|
||||
'table': unicode('chassis'),
|
||||
'key': unicode('chassis-1'),
|
||||
'action': unicode('delete'),
|
||||
'table': six.text_type('chassis'),
|
||||
'key': six.text_type('chassis-1'),
|
||||
'action': six.text_type('delete'),
|
||||
'value': None,
|
||||
}
|
||||
self.assertNotIn(expected_event, self.namespace.events)
|
||||
|
|
Loading…
Reference in New Issue