Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def menuhub_load(file):
- def datetime_to_float(d):
- return d.timestamp()
- pattern = re.compile(r"(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2}).(\d{3})") #use this to search for timestamp
- with open(file) as hubload_read:
- hublist = [] # list of timestamps
- hubtimes = [] # list of times taken for menu hub to load
- i = 0
- hub_value = True
- while(hub_value):
- line = hubload_read.readline()
- if line is not None:
- if 'generic hook' in line or 'other hook' in line: # hooks
- match = re.match(pattern, line)
- hublist.append(match.group()) # appends only the timestamp from the line
- else:
- hub_value = False
- while i in range(0, len(hublist) -1):
- hubtimes.append(datetime.strptime(hublist[i+1], "%Y-%m-%d %H:%M:%S.%f") - datetime.strptime(hublist[i], "%Y-%m-%d %H:%M:%S.%f")) #subtracts the adjacent timestamps associated with each hook
- i += 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement