Skip to content
This repository was archived by the owner on May 29, 2025. It is now read-only.

Commit a4d392a

Browse files
committed
Improve error handling for CPUByCommandLine.py
1 parent 5d5e97e commit a4d392a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

bin/CPUByCommandLine.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@
2727
from __future__ import print_function
2828

2929
import re
30+
import os
3031
import sys
3132

32-
commandlines = open("Processes_ProcessCommandLines.csv").readlines()
33-
cpuusages = open("CPU_Usage_(Precise)_Randomascii_CPU_Summary_by_Process.csv").readlines()
33+
command_line_csv = 'Processes_ProcessCommandLines.csv'
34+
cpu_usage_csv = 'CPU_Usage_(Precise)_Randomascii_CPU_Summary_by_Process.csv'
35+
36+
if not os.path.exists(command_line_csv) or not os.path.exists(cpu_usage_csv):
37+
print('Required .csv files are missing. To generate them run:')
38+
print('wpaexporter -i trace.etl -profile CPUUsageByCommandLine.wpaProfile')
39+
sys.exit(0)
40+
41+
commandlines = open(command_line_csv).readlines()
42+
cpuusages = open(cpu_usage_csv).readlines()
3443

3544
commandLinesByProcess = {}
3645
for line in commandlines[1:]:

0 commit comments

Comments
 (0)