Fix python3 compatibility issues in examples
Change-Id: I024207864668751455874cf3cb60de31cc01de87
This commit is contained in:
@@ -65,7 +65,7 @@ class VolumeCreator(task.Task):
|
||||
|
||||
# Assume there is no ordering dependency between volumes
|
||||
flow = uf.Flow("volume-maker")
|
||||
for i in xrange(0, VOLUME_COUNT):
|
||||
for i in range(0, VOLUME_COUNT):
|
||||
flow.add(VolumeCreator(volume_id="vol-%s" % (i)))
|
||||
|
||||
if SERIAL:
|
||||
|
@@ -43,7 +43,7 @@ from taskflow.utils import misc
|
||||
class AttrDict(object):
|
||||
def __init__(self, **kwargs):
|
||||
self._attrs = {}
|
||||
for (k, v) in kwargs.iteritems():
|
||||
for (k, v) in kwargs.items():
|
||||
if ' ' in k or k in ('self',) or not len(k):
|
||||
raise AttributeError("Invalid attribute name")
|
||||
self._attrs[k] = v
|
||||
@@ -66,7 +66,7 @@ class UrlCaller(object):
|
||||
|
||||
def send(self, url, data, status_cb=None):
|
||||
sleep_time = float(self._send_time) / 25
|
||||
for i in xrange(0, len(data)):
|
||||
for i in range(0, len(data)):
|
||||
time.sleep(sleep_time)
|
||||
if status_cb:
|
||||
status_cb(float(i) / len(data))
|
||||
|
@@ -8,7 +8,7 @@ executing first==1.0
|
||||
After running:
|
||||
Flow state: SUSPENDED
|
||||
boom==1.0: SUCCESS, result=None
|
||||
first==1.0: SUCCESS, result=u'ok'
|
||||
first==1.0: SUCCESS, result=ok
|
||||
second==1.0: PENDING, result=None
|
||||
|
||||
Resuming and running again:
|
||||
@@ -17,5 +17,5 @@ executing second==1.0
|
||||
At the end:
|
||||
Flow state: SUCCESS
|
||||
boom==1.0: SUCCESS, result=None
|
||||
first==1.0: SUCCESS, result=u'ok'
|
||||
second==1.0: SUCCESS, result=u'ok'
|
||||
first==1.0: SUCCESS, result=ok
|
||||
second==1.0: SUCCESS, result=ok
|
||||
|
@@ -43,7 +43,7 @@ def print_task_states(flowdetail, msg):
|
||||
items = sorted((td.name, td.version, td.state, td.results)
|
||||
for td in flowdetail)
|
||||
for item in items:
|
||||
print("%s==%s: %s, result=%r" % item)
|
||||
print("%s==%s: %s, result=%s" % item)
|
||||
|
||||
|
||||
def get_backend():
|
||||
|
@@ -36,7 +36,7 @@ def _exec(cmd, add_env=None):
|
||||
rc = proc.returncode
|
||||
if rc != 0:
|
||||
raise RuntimeError("Could not run %s [%s]", cmd, rc)
|
||||
print(stdout)
|
||||
print(stdout.decode())
|
||||
|
||||
|
||||
def _path_to(name):
|
||||
|
@@ -53,8 +53,9 @@ def run_example(name):
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
output = obj.communicate()
|
||||
if output[1]:
|
||||
raise RuntimeError('Example wrote to stderr:\n%s' % output[1])
|
||||
return output[0]
|
||||
raise RuntimeError('Example wrote to stderr:\n%s'
|
||||
% output[1].decode())
|
||||
return output[0].decode()
|
||||
|
||||
|
||||
def expected_output_path(name):
|
||||
|
Reference in New Issue
Block a user