代码拉取完成,页面将自动刷新
同步操作将从 src-openEuler/blktrace 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 0980a46e463b1c4286dab77a2a8a3f38dd2266b4 Mon Sep 17 00:00:00 2001
From: Vincent Legoll <vincent.legoll@gmail.com>
Date: Fri, 20 Mar 2020 22:44:59 +0100
Subject: [PATCH 12/15] btt_plot.py: Use `with open() as ...` context manager
to automatically handle close()
Signed-off-by: Vincent Legoll <vincent.legoll@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
btt/btt_plot.py | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/btt/btt_plot.py b/btt/btt_plot.py
index fcd5838..89ef54f 100755
--- a/btt/btt_plot.py
+++ b/btt/btt_plot.py
@@ -171,14 +171,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:
@@ -388,11 +389,12 @@ 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
#----------------------------------------------------------------------
--
1.8.3.1
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。