From: Jens Axboe <axboe@kernel.dk>
To: linux-btrace@vger.kernel.org
Subject: Recent changes (master)
Date: Sat, 21 Mar 2020 12:00:02 +0000 [thread overview]
Message-ID: <20200321120002.367881BC0175@kernel.dk> (raw)
In-Reply-To: <20130320050001.E340522DFC@kernel.dk>
The following changes since commit f4f8ef7cdea138cfaa2f3ca0ee31fa23d3bcf1cc:
fix parallel build of btt and blkiomon (2020-01-16 13:33:59 -0700)
are available in the Git repository at:
git://git.kernel.dk/blktrace.git master
for you to fetch changes up to db4f6340e04716285ea56fe26d76381c3adabe58:
btt_plot.py: Use `with open() as ...` context manager (2020-03-20 15:53:50 -0600)
----------------------------------------------------------------
Vincent Legoll (10):
btt_plot.py: Use sum() instead of open-coding it to compute list average
bno_plot.py: Use shutil.rmtree() instead of os.system('/bin/rm')
bno_plot.py: Use `with open() as ...` context manager to automatically handle close()
btt_plot.py: Fix pylint: wrong-import-order
btt_plot.py: Fix pylint: len-as-condition
btt_plot.py: Fix pylint: singleton-comparison
btt_plot.py: Fix pylint: no-else-return
bno_plot.py: Fix pylint: len-as-condition
bno_plot.py: Fix pylint: singleton-comparison
btt_plot.py: Use `with open() as ...` context manager
btt/bno_plot.py | 27 +++++++++++++-------------
btt/btt_plot.py | 60 ++++++++++++++++++++++++++++-----------------------------
2 files changed, 42 insertions(+), 45 deletions(-)
---
Diff of recent changes:
diff --git a/btt/bno_plot.py b/btt/bno_plot.py
index f05cfdc..3aa4e19 100644
--- a/btt/bno_plot.py
+++ b/btt/bno_plot.py
@@ -40,7 +40,7 @@ To exit the plotter, enter 'quit' or ^D at the 'gnuplot> ' prompt.
from __future__ import absolute_import
from __future__ import print_function
-import getopt, glob, os, sys, tempfile
+import getopt, glob, os, sys, tempfile, shutil
verbose = 0
cmds = """
@@ -76,7 +76,7 @@ def parse_args(in_args):
elif o in ('-K', '--keys-below'):
keys_below = True
- if len(args) > 0: bnos = args
+ if args: bnos = args
else: bnos = glob.glob('blknos*[rw].dat')
return (bnos, keys_below)
@@ -98,21 +98,20 @@ if __name__ = '__main__':
for f in bnos:
t = '%s/%s' % (tmpdir, f)
- fo = open(t, 'w')
- for line in open(f, 'r'):
- fld = line.split(None)
- print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
- fo.close()
+ with open(t, 'w') as fo:
+ with open(f, 'r') as fi:
+ for line in fi:
+ fld = line.split(None)
+ print(fld[0], fld[1], int(fld[2])-int(fld[1]), file=fo)
t = t[t.rfind('/')+1:]
- if plot_cmd = None: plot_cmd = "splot '%s'" % t
+ if plot_cmd is None: plot_cmd = "splot '%s'" % t
else: plot_cmd = "%s,'%s'" % (plot_cmd, t)
- fo = open('%s/plot.cmds' % tmpdir, 'w')
- print(cmds, file=fo)
- if len(bnos) > 10 or keys_below: print('set key below', file=fo)
- print(plot_cmd, file=fo)
- fo.close()
+ with open('%s/plot.cmds' % tmpdir, 'w') as fo:
+ print(cmds, file=fo)
+ if len(bnos) > 10 or keys_below: print('set key below', file=fo)
+ print(plot_cmd, file=fo)
pid = os.fork()
if pid = 0:
@@ -125,4 +124,4 @@ if __name__ = '__main__':
sys.exit(1)
os.waitpid(pid, 0)
- os.system('/bin/rm -rf ' + tmpdir)
+ shutil.rmtree(tmpdir)
diff --git a/btt/btt_plot.py b/btt/btt_plot.py
index 76fcca8..40bc71f 100755
--- a/btt/btt_plot.py
+++ b/btt/btt_plot.py
@@ -57,6 +57,7 @@ Arguments:
from __future__ import absolute_import
from __future__ import print_function
+import getopt, glob, os, sys
import six
from six.moves import range
__author__ = 'Alan D. Brunelle <alan.brunelle@hp.com>'
@@ -65,7 +66,6 @@ __author__ = 'Alan D. Brunelle <alan.brunelle@hp.com>'
import matplotlib
matplotlib.use('Agg')
-import getopt, glob, os, sys
import matplotlib.pyplot as plt
plot_size = [10.9, 8.4] # inches...
@@ -113,8 +113,8 @@ def get_data(files):
"""Returns new min, max, and float value for those passed in"""
v = float(v)
- if mn = None or v < mn: mn = v
- if mx = None or v > mx: mx = v
+ if mn is None or v < mn: mn = v
+ if mx is None or v > mx: mx = v
return mn, mx, v
#--------------------------------------------------------------
@@ -125,10 +125,7 @@ def get_data(files):
def _avg(vals):
"""Computes average for array of values passed"""
- total = 0.0
- for val in vals:
- total += val
- return total / len(vals)
+ return sum(vals) / len(vals)
#------------------------------------------------------
if len(xs) < 1000:
@@ -171,14 +168,15 @@ def get_data(files):
xs = []
ys = []
- for line in open(file, 'r'):
- f = line.rstrip().split(None)
- if line.find('#') = 0 or len(f) < 2:
- continue
- (min_x, max_x, x) = check(min_x, max_x, f[0])
- (min_y, max_y, y) = check(min_y, max_y, f[1])
- xs.append(x)
- ys.append(y)
+ with open(file, 'r') as fi:
+ for line in fi:
+ f = line.rstrip().split(None)
+ if line.find('#') = 0 or len(f) < 2:
+ continue
+ (min_x, max_x, x) = check(min_x, max_x, f[0])
+ (min_y, max_y, y) = check(min_y, max_y, f[1])
+ xs.append(x)
+ ys.append(y)
db[file] = {'x':xs, 'y':ys}
if len(xs) > 10:
@@ -238,7 +236,7 @@ def parse_args(args):
elif o in ('-v', '--verbose'):
verbose = True
- if type = None and not generate_all:
+ if type is None and not generate_all:
fatal('Need type of data files to process - (-t <type>)')
return args
@@ -247,7 +245,7 @@ def parse_args(args):
def gen_title(fig, type, title_str):
"""Sets the title for the figure based upon the type /or/ user title"""
- if title_str != None:
+ if title_str is not None:
pass
elif type = 'aqd':
title_str = 'Average Queue Depth'
@@ -312,7 +310,7 @@ def generate_output(type, db):
#----------------------------------------------------------------------
global add_legend, output_file, title_str, verbose
- if output_file != None:
+ if output_file is not None:
ofile = output_file
else:
ofile = '%s.png' % type
@@ -343,7 +341,7 @@ def generate_output(type, db):
if type = 'bnos':
ax.plot(dat['x'], dat['y'], color(idx, 'marker'),
markersize=1)
- elif dat['ax'] = None:
+ elif dat['ax'] is None:
continue # Don't add legend
else:
ax.plot(dat['ax'], dat['ay'], color(idx, 'line'),
@@ -352,7 +350,7 @@ def generate_output(type, db):
legends.append(get_base(file))
idx += 1
- if add_legend and len(legends) > 0:
+ if add_legend and legends:
gen_legends(ax, legends)
plt.savefig(ofile)
@@ -388,23 +386,23 @@ def do_live(files):
def get_live_data(fn):
xs = []
ys = []
- for line in open(fn, 'r'):
- f = line.rstrip().split()
- if f[0] != '#' and len(f) = 2:
- xs.append(float(f[0]))
- ys.append(float(f[1]))
+ with open(fn, 'r') as fi:
+ for line in fi:
+ f = line.rstrip().split()
+ if f[0] != '#' and len(f) = 2:
+ xs.append(float(f[0]))
+ ys.append(float(f[1]))
return xs, ys
#----------------------------------------------------------------------
def live_sort(a, b):
if a[0] = 'sys' and b[0] = 'sys':
return 0
- elif a[0] = 'sys' or a[2][0] < b[2][0]:
+ if a[0] = 'sys' or a[2][0] < b[2][0]:
return -1
- elif b[0] = 'sys' or a[2][0] > b[2][0]:
+ if b[0] = 'sys' or a[2][0] > b[2][0]:
return 1
- else:
- return 0
+ return 0
#----------------------------------------------------------------------
def turn_off_ticks(ax):
@@ -453,7 +451,7 @@ if __name__ = '__main__':
output_file = title_str = type = None
for t in types:
files = get_files(t)
- if len(files) = 0:
+ if files = 0:
continue
elif t = 'bnos':
do_bnos(files)
@@ -463,7 +461,7 @@ if __name__ = '__main__':
generate_output(t, get_data(files))
continue
- elif len(files) < 1:
+ elif not files:
fatal('Need data files to process')
else:
generate_output(type, get_data(files))
next prev parent reply other threads:[~2020-03-21 12:00 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-20 5:00 Recent changes (master) Jens Axboe
2013-08-02 4:00 ` Jens Axboe
2013-12-04 4:56 ` Jens Axboe
2014-04-12 12:00 ` Jens Axboe
2014-09-09 12:00 ` Jens Axboe
2014-09-26 12:00 ` Jens Axboe
2015-02-19 13:00 ` Jens Axboe
2015-08-21 12:00 ` Jens Axboe
2015-09-16 12:00 ` Jens Axboe
2016-01-09 13:00 ` Jens Axboe
2016-02-10 13:00 ` Jens Axboe
2016-04-26 12:00 ` Jens Axboe
2016-05-04 12:00 ` Jens Axboe
2016-05-06 12:00 ` Jens Axboe
2016-05-20 12:00 ` Jens Axboe
2016-08-24 12:00 ` Jens Axboe
2017-01-27 13:00 ` Jens Axboe
2017-11-05 13:00 ` Jens Axboe
2017-11-06 13:00 ` Jens Axboe
2017-11-08 13:00 ` Jens Axboe
2018-01-24 13:00 ` Jens Axboe
2018-01-25 13:00 ` Jens Axboe
2018-04-10 12:00 ` Jens Axboe
2018-05-03 12:00 ` Jens Axboe
2018-05-17 12:00 ` Jens Axboe
2018-08-31 12:00 ` Jens Axboe
2018-09-01 12:00 ` Jens Axboe
2019-05-22 12:00 ` Jens Axboe
2019-09-17 12:00 ` Jens Axboe
2019-09-25 12:00 ` Jens Axboe
2020-01-17 13:00 ` Jens Axboe
2020-03-21 12:00 ` Jens Axboe [this message]
2020-05-08 12:00 ` Jens Axboe
2020-05-21 12:00 ` Jens Axboe
2021-02-20 13:00 ` Jens Axboe
2021-04-20 12:00 ` Jens Axboe
2021-06-15 11:59 ` Jens Axboe
2021-06-29 12:00 ` Jens Axboe
2021-10-22 12:00 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2024-01-18 13:00 Jens Axboe
2024-06-13 12:00 Jens Axboe
2024-10-09 12:00 Jens Axboe
2025-01-31 13:00 Jens Axboe
2025-03-20 12:00 Jens Axboe
2025-12-11 13:00 Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200321120002.367881BC0175@kernel.dk \
--to=axboe@kernel.dk \
--cc=linux-btrace@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).