Skip to content

Instantly share code, notes, and snippets.

@MrDOS
Created October 15, 2012 19:40
Show Gist options
  • Save MrDOS/3894781 to your computer and use it in GitHub Desktop.
Save MrDOS/3894781 to your computer and use it in GitHub Desktop.
Determine the extraction speed of a disc drive based on an EAC log.
#! /usr/bin/python
import sys, re
DRIVE_PATTERN = "Used drive : (.+?) Adapter"
TRACK_PATTERN = "([0-9]+) +\| +([0-9]+):([0-5][0-9].[0-9]{2}) \| +([0-9]+):([0-5][0-9].[0-9]{2}) \| +([0-9]+) +\| +([0-9]+)"
SPEED_PATTERN = "Extraction speed ([0-9]+.[0-9]) X"
def parse(log):
if not log.startswith("Exact Audio Copy V"):
raise Exception("Not an EAC log")
drive = re.search(DRIVE_PATTERN, log).group(1)
tracks = re.findall(TRACK_PATTERN, log)
speeds = re.findall(SPEED_PATTERN, log)
if len(speeds) == 0:
raise Exception('No extraction speeds found')
total_time = 0
total_speed = 0
weighted_speed = 0
for i in range(len(speeds)):
time = int(tracks[i][3]) * 60 + float(tracks[i][4])
total_time += time
total_speed += float(speeds[i])
weighted_speed += time * float(speeds[i])
print "Average/weighted average extraction speed for %s: %.2f/%.2f" \
% (drive, total_speed / len(speeds), weighted_speed / total_time)
if __name__ == "__main__":
if len(sys.argv) > 1:
logf = open(sys.argv[1])
log = logf.read()
logf.close
else:
log = sys.stdin.read()
parse(log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment