summaryrefslogtreecommitdiff
path: root/asltool.py
blob: 9616d17bf3c248aefeb9b39f996690801020fe44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import sys
import os
import msvcrt
from timeit import timeit as time
from time import clock as clock
shotcount=0
pauseinterval=[]
shotlist=[]
def metadata():
	global name
	name=input("\nenter movie name:\n")
	print("press enter to start")
	keystroke=str(msvcrt.getch())[-2]
	if keystroke=="r":
		print("counter begins")
		key()
def key():
	clock()
	global shotlist
	global shotcount
	global keystroke
	global pauseinterval
	keystroke=str(msvcrt.getch())[-2]
	if keystroke=="s":
		timestamp=clock()
		shotcount=shotcount+1
		shotlist.append((shotcount,timestamp))
		key() 
	elif keystroke=="p": pause()
	elif keystroke=="e" : reset()
def pause():
	print("paused")
	global pauseinterval
	startpause=clock()
	startagain=str(msvcrt.getch())[-2]
	if startagain=="p": 
		endpause=clock()
		print("restarted")
		pauseinterval.append(endpause-startpause)
		key()
	elif startagain=="e": reset()
	else: pass
def reset():
	global totaltime
	global ASL
	totaltime=clock()
	for pausetime in pauseinterval: totaltime=totaltime-pausetime
	print(totaltime)
	try: 
		totaltime/shotcount
	except ZeroDivisionError:
		sys.exit("no shots recorded")
	ASL=totaltime/shotcount
	print("number of shots=%d"%shotcount)	
	print("ASL =%fseconds"%ASL)
	reportgenerator()
def reportgenerator():
	fileopen=open(r"%s.ASLreport"%name,mode="w")
	fileopen.write(
	"ASL report for %s \n\n Record Time=%f\n Recorded Shots=%d\n ASL=%f\nShot Timestamps:\n%s"%(name,totaltime,shotcount,ASL,(str(shotdata) for shotdata in shotlist)))

if __name__=="__main__":
	metadata()