Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 8b2f0cb

Browse files
tebrandtrafaeljw
authored andcommitted
pm-graph: v5.12, code revamp for python3.12
sleepgraph/bootgraph function correctly in python3.12 but include a slew of deprecation warnings for unsupported regexes. This patch fixes up all the strings in the code so that it comforms with python3.12 standards. Signed-off-by: Todd Brandt <todd.e.brandt@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent c9d197e commit 8b2f0cb

File tree

2 files changed

+508
-508
lines changed

2 files changed

+508
-508
lines changed

tools/power/pm-graph/bootgraph.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ def __init__(self):
7777
fp.close()
7878
self.testdir = datetime.now().strftime('boot-%y%m%d-%H%M%S')
7979
def kernelVersion(self, msg):
80-
m = re.match('^[Ll]inux *[Vv]ersion *(?P<v>\S*) .*', msg)
80+
m = re.match(r'^[Ll]inux *[Vv]ersion *(?P<v>\S*) .*', msg)
8181
if m:
8282
return m.group('v')
8383
return 'unknown'
8484
def checkFtraceKernelVersion(self):
85-
m = re.match('^(?P<x>[0-9]*)\.(?P<y>[0-9]*)\.(?P<z>[0-9]*).*', self.kernel)
85+
m = re.match(r'^(?P<x>[0-9]*)\.(?P<y>[0-9]*)\.(?P<z>[0-9]*).*', self.kernel)
8686
if m:
8787
val = tuple(map(int, m.groups()))
8888
if val >= (4, 10, 0):
@@ -324,32 +324,32 @@ def parseKernelLog():
324324
idx = line.find('[')
325325
if idx > 1:
326326
line = line[idx:]
327-
m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
327+
m = re.match(r'[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
328328
if(not m):
329329
continue
330330
ktime = float(m.group('ktime'))
331331
if(ktime > 120):
332332
break
333333
msg = m.group('msg')
334334
data.dmesgtext.append(line)
335-
if(ktime == 0.0 and re.match('^Linux version .*', msg)):
335+
if(ktime == 0.0 and re.match(r'^Linux version .*', msg)):
336336
if(not sysvals.stamp['kernel']):
337337
sysvals.stamp['kernel'] = sysvals.kernelVersion(msg)
338338
continue
339-
m = re.match('.* setting system clock to (?P<d>[0-9\-]*)[ A-Z](?P<t>[0-9:]*) UTC.*', msg)
339+
m = re.match(r'.* setting system clock to (?P<d>[0-9\-]*)[ A-Z](?P<t>[0-9:]*) UTC.*', msg)
340340
if(m):
341341
bt = datetime.strptime(m.group('d')+' '+m.group('t'), '%Y-%m-%d %H:%M:%S')
342342
bt = bt - timedelta(seconds=int(ktime))
343343
data.boottime = bt.strftime('%Y-%m-%d_%H:%M:%S')
344344
sysvals.stamp['time'] = bt.strftime('%B %d %Y, %I:%M:%S %p')
345345
continue
346-
m = re.match('^calling *(?P<f>.*)\+.* @ (?P<p>[0-9]*)', msg)
346+
m = re.match(r'^calling *(?P<f>.*)\+.* @ (?P<p>[0-9]*)', msg)
347347
if(m):
348348
func = m.group('f')
349349
pid = int(m.group('p'))
350350
devtemp[func] = (ktime, pid)
351351
continue
352-
m = re.match('^initcall *(?P<f>.*)\+.* returned (?P<r>.*) after (?P<t>.*) usecs', msg)
352+
m = re.match(r'^initcall *(?P<f>.*)\+.* returned (?P<r>.*) after (?P<t>.*) usecs', msg)
353353
if(m):
354354
data.valid = True
355355
data.end = ktime
@@ -359,7 +359,7 @@ def parseKernelLog():
359359
data.newAction(phase, f, pid, start, ktime, int(r), int(t))
360360
del devtemp[f]
361361
continue
362-
if(re.match('^Freeing unused kernel .*', msg)):
362+
if(re.match(r'^Freeing unused kernel .*', msg)):
363363
data.tUserMode = ktime
364364
data.dmesg['kernel']['end'] = ktime
365365
data.dmesg['user']['start'] = ktime

0 commit comments

Comments
 (0)