scripts/show_delta: port to python3
PATCH 1/1 scripts/show_delta: port to python3
Although commit f29b5f3e6fc0 ("show_delta: Update script to support python versions 2.5 through 3.3") claims that show_delta is python3-compatible, it uses some functions that were removed in python3: string.split, string.atof and string.find. Replace these with modern equivalents.
Also, to suppress newlines from print(), the 'end' parameter is now required.
With these changes, the script can be used under python3, so update the shebang line to reflect this.
Signed-off-by Jonathan Davies <[email protected]>
--- scripts/show_delta | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
scripts/show_delta +5 -5
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-2.0-only # # show_deltas: Read list of printk messages instrumented with
@@ -46,8 +46,8 @@ def get_time(line): raise ValueError # split on closing bracket - (time_str, rest) = string.split(line[1:],']',1) - time = string.atof(time_str) + (time_str, rest) = line[1:].split(']', 1) + time = float(time_str) #print "time=", time return (time, rest)
@@ -111,7 +111,7 @@ def main(): (time, rest) = get_time(line) except: continue - if string.find(rest, base_str)==1: + if rest.find(base_str)==1: base_time = time found = 1 # stop at first match
@@ -123,6 +123,6 @@ def main(): base_time = 0.0 for line in lines: - print (convert_line(line, base_time),) + print (convert_line(line, base_time), end='') main()
Signature · 1 line
2.34.1