values = []
if os.path.isfile(target_file):
- with open(target_file, 'r') as cpu_rec:
- for item in cpu_rec.readlines()[1:]:
- tstamp, usage = item.strip().split(',')
- values.append([int(tstamp), float(usage)])
+ with open(target_file, 'r') as hw_rec:
+ for item in hw_rec.readlines()[1:]:
+ tstamp, cpu_usage, mem_usage = item.strip().split(',')
+ values.append([int(tstamp), \
+ round(float(cpu_usage), 2), round(float(mem_usage), 2)])
return values
"""Remove log file"""
if os.path.isfile(target_file):
- with open(target_file, 'r') as hw_rec:
- for item in hw_rec.readlines()[1:]:
- tstamp, cpu_usage, mem_usage = item.strip().split(',')
- values.append([int(tstamp), \
- round(float(cpu_usage), 2), round(float(mem_usage), 2)])
+ with open(target_file, 'r') as record_file:
+ pid = int(record_file.readline().strip())
+ self.stop_recording(pid)
+ if preserve_file is False and os.path.isfile(target_file):
+ os.remove(target_file)
def stop_recording_without_cleanup(self, target_file):
"""Stop the process"""