-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgre_timer.py
More file actions
executable file
·44 lines (40 loc) · 1.15 KB
/
gre_timer.py
File metadata and controls
executable file
·44 lines (40 loc) · 1.15 KB
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
import sys, tty, time
# v 0.0
# Scrath my itch
# -------------------------
# v 0.1
# type -> quants, verbal
# number of questions > 0
# time for each question kept constant at 2 minutes
# -------------------------
# v 0.2
# question type
# file path to read questions (starting with csv)
# Show timer for each
# -------------------------
# v 0.3
# make a gui
# -------------------------
tty.setcbreak(sys.stdin)
start_time, end_time, old_time, cur_time = 0, 0, 0, 0
file_ptr = open('test-time.txt', mode='a+')
file_ptr.write(time.ctime()+"\n")
while True:
key = ord(sys.stdin.read(1)) # key captures the key-code
# based on the input we do something - in this case print something
if old_time == 0:
start_time, old_time= time.time(), time.time()
if key==32 or key==97:
cur_time = time.time()
timing = str((cur_time - old_time))[:4] + ' Seconds\n'
old_time, end_time = cur_time, cur_time
file_ptr.write(timing)
print(timing)
if key==97:
file_ptr.write('--'*10 + '\n')
timing = str((end_time - start_time)/60) + ' Minutes\n'
file_ptr.write('Total timing : '+timing)
file_ptr.write('-*-'*10 + '\n')
file_ptr.close()
break
sys.exit(0)