blob: c2539706e782f4cdbe2eb232b4d6ab904335df47 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
#!/git/aslclass.py
# Copyright 2013 Aditya Naik
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0
import sys
import os
import msvcrt
from timeit import timeit as time
from time import clock as clock
class ASLreport:
def __init__(self):
self.shotcount=0
self.pauseinterval=[]
self.shotlist=[]
def metadata(self):
self.name=input("\nenter movie name:\n")
self.report=input("\nwant to generate report file?(y/n)\n")
print("press enter to start")
keystroke=str(msvcrt.getch())[-2]
if keystroke=="r":
print("counter begins")
self.key()
else: print("Unknown keystroke ")
def key(self):
clock()
tottime=0
keystroke=str(msvcrt.getch())[-2]
if keystroke=="s":
timestamp=clock()
self.shotcount=self.shotcount+1
if self.pauseinterval!=[]:
for pausetime in self.pauseinterval: tottime=tottime+pausetime
actualtime=float(timestamp)-float(tottime)
# self.shotlist.append((self.shotcount,actualtime ))
print("Shot #%d at %fs "%(self.shotcount,actualtime))
else:
self.shotlist.append((self.shotcount,timestamp ))
print("Shot #%d at %fs "%(self.shotcount,timestamp))
self.key()
elif keystroke=="p": self.pause()
elif keystroke=="e" : self.reset()
else: print("Unkown keystroke")
def pause(self):
print("paused")
self.startpause=clock()
startagain=str(msvcrt.getch())[-2]
if startagain=="p":
self.endpause=clock()
print("restarted")
self.pauseinterval.append(self.endpause-self.startpause)
self.key()
elif startagain=="e": self.reset()
else: print("Unknown keystroke")
def reset(self):
self.totaltime=clock()
for pausetime in self.pauseinterval:
self.totaltime=self.totaltime-pausetime
print(self.totaltime)
try: self.totaltime/self.shotcount
except ZeroDivisionError: sys.exit("no shots recorded")
self.ASL=self.totaltime/self.shotcount
print("number of shots=%d"%self.shotcount)
print("ASL =%fseconds"%self.ASL)
if self.report=="y": self.reportgenerator()
def reportgenerator(self):
fileopen=open(r"%s.ASLreport"%self.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"%(self.name,self.totaltime,self.shotcount,self.ASL,str(self.shotlist)))
if __name__=="__main__":
ASLreport().metadata()
|