make fio scripts python3-ready (part 2)
PATCH 1/1 make fio scripts python3-ready (part 2)
NOTE: this patch (part 2) is in addition to commit 5eac3b00238b (this patch was missed on that submit/commit (part 1)).
Many distributions are moving to python3 by default. This is another patch to make the python scripts in fio python3-ready.
Conversion was facilitated with automated tools.
The modified scripts pass rudimentary testing when run under python2.7 as well as python3.
--- tools/fio_jsonplus_clat2csv | 13 +++-- tools/plot/fio2gnuplot | 97 +++++++++++++++++++------------------ 2 files changed, 60 insertions(+), 50 deletions(-)
tools/fio_jsonplus_clat2csv +9 -4
@@ -1,4 +1,5 @@ #!/usr/bin/python2.7 +# Note: this script is python2 and python3 compatible. # # fio_jsonplus_clat2csv #
@@ -60,9 +61,13 @@ # 10304ns is the 100th percentile for read latency # +from __future__ import absolute_import +from __future__ import print_function import os import json import argparse +import six +from six.moves import range def parse_args():
@@ -87,7 +92,7 @@ def percentile(idx, run_total): def more_lines(indices, bins): - for key, value in indices.iteritems(): + for key, value in six.iteritems(indices): if value < len(bins[key]): return True
@@ -116,8 +121,8 @@ def main(): "Are you sure you are using json+ output?") bins[ddir] = [[int(key), value] for key, value in - jsondata['jobs'][jobnum][ddir][bins_loc] - ['bins'].iteritems()] + six.iteritems(jsondata['jobs'][jobnum][ddir][bins_loc] + ['bins'])] bins[ddir] = sorted(bins[ddir], key=lambda bin: bin[0]) run_total[ddir] = [0 for x in range(0, len(bins[ddir]))]
@@ -165,7 +170,7 @@ def main(): output.write(", , , ") output.write("\n") - print "{0} generated".format(outfile) + print("{0} generated".format(outfile)) if __name__ == '__main__':
tools/plot/fio2gnuplot +51 -46
226 lines not on this page · raw message
Signature · 1 line
2.17.0
Jens Axboe
AppliedQuoted 10 lines · Bill O'Donnell
NOTE: this patch (part 2) is in addition to commit
5eac3b00238b(this patch was missed on that submit/commit (part 1)).Many distributions are moving to python3 by default. This is another patch to make the python scripts in fio python3-ready.
Conversion was facilitated with automated tools.
The modified scripts pass rudimentary testing when run under python2.7 as well as python3.
Applied, thanks.
Signature · 1 line
Jens Axboe