diff options
author | Ivan A. Melnikov <imelnikov@griddynamics.com> | 2013-10-10 14:14:03 +0400 |
---|---|---|
committer | Ivan A. Melnikov <imelnikov@griddynamics.com> | 2013-10-10 14:51:35 +0400 |
commit | c5b84d021df305d5022a1012d788f855b7a2c40a (patch) | |
tree | 1500cd49157eb1fe262f45e04dc237325d5250e2 | |
parent | 026fc8329a94d9678ef8b6807b6c5de456930c14 (diff) | |
download | taskflow-c5b84d021df305d5022a1012d788f855b7a2c40a.tar.gz |
Fix python3 compatibility issues in examples
Change-Id: I024207864668751455874cf3cb60de31cc01de87
-rw-r--r-- | taskflow/examples/create_parallel_volume.py | 2 | ||||
-rw-r--r-- | taskflow/examples/fake_billing.py | 4 | ||||
-rw-r--r-- | taskflow/examples/resume_from_backend.out.txt | 6 | ||||
-rw-r--r-- | taskflow/examples/resume_from_backend.py | 2 | ||||
-rw-r--r-- | taskflow/examples/resume_many_flows.py | 2 | ||||
-rw-r--r-- | taskflow/tests/test_examples.py | 5 |
6 files changed, 11 insertions, 10 deletions
diff --git a/taskflow/examples/create_parallel_volume.py b/taskflow/examples/create_parallel_volume.py index d14a541..402ba5a 100644 --- a/taskflow/examples/create_parallel_volume.py +++ b/taskflow/examples/create_parallel_volume.py @@ -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: diff --git a/taskflow/examples/fake_billing.py b/taskflow/examples/fake_billing.py index 0d4bbc8..446f160 100644 --- a/taskflow/examples/fake_billing.py +++ b/taskflow/examples/fake_billing.py @@ -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)) diff --git a/taskflow/examples/resume_from_backend.out.txt b/taskflow/examples/resume_from_backend.out.txt index e4a30cf..6d1116d 100644 --- a/taskflow/examples/resume_from_backend.out.txt +++ b/taskflow/examples/resume_from_backend.out.txt @@ -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 diff --git a/taskflow/examples/resume_from_backend.py b/taskflow/examples/resume_from_backend.py index d7c713e..519966e 100644 --- a/taskflow/examples/resume_from_backend.py +++ b/taskflow/examples/resume_from_backend.py @@ -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(): diff --git a/taskflow/examples/resume_many_flows.py b/taskflow/examples/resume_many_flows.py index 93d3e2f..8a7b346 100644 --- a/taskflow/examples/resume_many_flows.py +++ b/taskflow/examples/resume_many_flows.py @@ -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): diff --git a/taskflow/tests/test_examples.py b/taskflow/tests/test_examples.py index d7bf16b..906701a 100644 --- a/taskflow/tests/test_examples.py +++ b/taskflow/tests/test_examples.py @@ -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): |