From 749f65e3e30e857301e44db4a87eca99d45cdc66 Mon Sep 17 00:00:00 2001 From: Craig Rodrigues Date: Thu, 19 Nov 2015 00:01:52 +0000 Subject: Use print as a function for Python 3 [PEP 3105] Import print_function from the __future__ module to activate this for Python 2. This works as far back as Python 2.6.0a2: https://docs.python.org/2/library/__future__.html [PEP 3105] https://www.python.org/dev/peps/pep-3105/ --- tools/sched/schedgraph.py | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'tools/sched') diff --git a/tools/sched/schedgraph.py b/tools/sched/schedgraph.py index 0723dc3324e7..6d8a4b9ada14 100644 --- a/tools/sched/schedgraph.py +++ b/tools/sched/schedgraph.py @@ -26,6 +26,7 @@ # # $FreeBSD$ +from __future__ import print_function import sys import re import random @@ -142,7 +143,7 @@ class Colormap: color = self.map[name] except: color = colors[random.randrange(0, len(colors))] - print "Picking random color", color, "for", name + print("Picking random color", color, "for", name) self.map[name] = color self.table.append((name, color)) return (color) @@ -736,9 +737,9 @@ class StateEvent(Event): color = colormap.lookup(self.name) if (duration < 0): duration = 0 - print "Unsynchronized timestamp" - print self.cpu, self.timestamp - print next.cpu, next.timestamp + print("Unsynchronized timestamp") + print(self.cpu, self.timestamp) + print(next.cpu, next.timestamp) delta = duration / canvas.ratio l = canvas.create_rectangle(xpos, ypos, xpos + delta, ypos - 10, fill=color, width=0, @@ -762,9 +763,9 @@ class CountEvent(Event): self.duration = duration = next.timestamp - self.timestamp if (duration < 0): duration = 0 - print "Unsynchronized timestamp" - print self.cpu, self.timestamp - print next.cpu, next.timestamp + print("Unsynchronized timestamp") + print(self.cpu, self.timestamp) + print(next.cpu, next.timestamp) self.attrs.insert(0, ("count", self.count)) self.attrs.insert(1, ("duration", ticks2sec(duration))) delta = duration / canvas.ratio @@ -941,7 +942,7 @@ class KTRFile: try: ifp = open(file) except: - print "Can't open", file + print("Can't open", file) sys.exit(1) # quoteexp matches a quoted string, no escaping @@ -989,14 +990,14 @@ class KTRFile: status.startup("Parsing line " + str(lineno)) m = ktrre.match(line); if (m == None): - print "Can't parse", lineno, line, + print("Can't parse", lineno, line, end=' ') continue; (index, cpu, timestamp, group, id, type, dat, dat1, attrstring) = m.groups(); if (dat == None): dat = dat1 if (self.checkstamp(timestamp) == 0): - print "Bad timestamp at", lineno, ":", - print cpu, timestamp + print("Bad timestamp at", lineno, ":", end=' ') + print(cpu, timestamp) continue # # Build the table of optional attributes @@ -1032,7 +1033,7 @@ class KTRFile: args = (dat, cpu, timestamp, attrs) e = self.makeevent(group, id, type, args) if (e == None): - print "Unknown type", type, lineno, line, + print("Unknown type", type, lineno, line, end=' ') def makeevent(self, group, id, type, args): e = None @@ -1098,9 +1099,9 @@ class KTRFile: if (self.stathz != 0): return (self.timespan() / self.ticks[0]) * int(self.stathz) # Pretend we have a 1ns clock - print "WARNING: No clock discovered and no frequency ", - print "specified via the command line." - print "Using fake 1ghz clock" + print("WARNING: No clock discovered and no frequency ", end=' ') + print("specified via the command line.") + print("Using fake 1ghz clock") return (oneghz); def fixup(self): @@ -1624,7 +1625,7 @@ class SchedGraph(Frame): return self.display.getstate(tag) if (len(sys.argv) != 2 and len(sys.argv) != 3): - print "usage:", sys.argv[0], " [clock freq in ghz]" + print("usage:", sys.argv[0], " [clock freq in ghz]") sys.exit(1) if (len(sys.argv) > 2): -- cgit v1.2.3