summaryrefslogtreecommitdiff
path: root/zuul/ansible/base/callback/zuul_json.py
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2019-08-27 09:41:57 +0200
committerMonty Taylor <mordred@inaugust.com>2019-08-27 09:42:43 +0200
commitdd6556f37618700f9975402019013038efe42fe7 (patch)
tree0ccaceb0c2a079bb9246e5ca2740a6b92d9e47ce /zuul/ansible/base/callback/zuul_json.py
parentd495f2f2af7ff47e95c94b290a95f5b38dd1833d (diff)
downloadzuul-dd6556f37618700f9975402019013038efe42fe7.tar.gz
Make json outfile seeking clearer
The magic number of 2 can be replaced by os.SEEK_END, and the seek call returns the length, so we don't need the tell call. Change-Id: I1aa5b568d9aab89440e221f8e09b552d05f2cc53
Diffstat (limited to 'zuul/ansible/base/callback/zuul_json.py')
-rw-r--r--zuul/ansible/base/callback/zuul_json.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/zuul/ansible/base/callback/zuul_json.py b/zuul/ansible/base/callback/zuul_json.py
index d3c88b452..4a2edcf6e 100644
--- a/zuul/ansible/base/callback/zuul_json.py
+++ b/zuul/ansible/base/callback/zuul_json.py
@@ -186,10 +186,10 @@ class CallbackModule(CallbackBase):
self._append_playbook(outfile, first_time)
def _append_playbook(self, outfile, first_time):
- outfile.seek(0, 2)
+ file_len = outfile.seek(0, os.SEEK_END)
# Remove three bytes to eat the trailing newline written by the
# json.dump. This puts the ',' on the end of lines.
- outfile.seek(outfile.tell() - 3)
+ outfile.seek(file_len - 3)
if not first_time:
outfile.write(',\n')
json.dump(self.playbook, outfile,