summaryrefslogtreecommitdiff
path: root/aslclass.py
diff options
context:
space:
mode:
Diffstat (limited to 'aslclass.py')
-rw-r--r--aslclass.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/aslclass.py b/aslclass.py
new file mode 100644
index 0000000..448053f
--- /dev/null
+++ b/aslclass.py
@@ -0,0 +1,63 @@
+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()
+
+ def key(self):
+ clock()
+ keystroke=str(msvcrt.getch())[-2]
+ if keystroke=="s":
+ timestamp=clock()
+ self.shotcount=self.shotcount+1
+ self.shotlist.append((self.shotcount,timestamp))
+ self.key()
+ elif keystroke=="p": self.pause()
+ elif keystroke=="e" : self.reset()
+
+ def pause(self):
+ print("paused")
+ startpause=clock()
+ startagain=str(msvcrt.getch())[-2]
+ if startagain=="p":
+ endpause=clock()
+ print("restarted")
+ self.pauseinterval.append(endpause-startpause)
+ self.key()
+ elif startagain=="e": self.reset()
+ else: pass
+
+ 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(shotdata) for shotdata in self.shotlist)))
+
+if __name__=="__main__":
+ ASLreport().metadata() \ No newline at end of file