-
Notifications
You must be signed in to change notification settings - Fork 0
/
alarmDB.old.py
62 lines (50 loc) · 1.53 KB
/
alarmDB.old.py
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
from tinydb import TinyDB, Query
import time
import datetime as dt
db = TinyDB('db.json')
q = Query()
def write(date, time, name, active, sound, vol, *argv):
i = {'date': date, 'time': time, 'name': name, 'active': active, 'sound': sound, 'vol': vol}
for arg in argv:
a,b = arg.split(':')
try:
b = eval(b)
except:
b = b
i[a] = b
db.insert(i)
def searchDT(date, time):
if db.search((q['date'] == date)&(q['time'] == time)) != []:
s = db.get((q['date'] == date)&(q['time'] == time))
return s
else:
return 'Not Found'
def printDB(clear=0):
if clear == 1:
db.purge()
for i in db:
print(i)
def cmdline():
t = input('Please Input Time (13:23:00): ')
d = input('Please Input Date (mm/dd/yyyy): ')
name = input('Name your alarm: ')
active = input('Do you want to enable your alarm? (y/n): ')
if active == 'y':
active = True
elif active == 'n':
active = False
mp3 = input('Please type the name of the sound for this alarm (include the extension): ')
vol = input('Volume (0.0 - 1.0): ')
print('Setting alarm...')
write(d, t, name, active, mp3, vol)
print('Alarm set!')
def testAdd(amount, startTime, date):
a, b, c = startTime.split(':')
for i in range(amount):
b2 = str(int(b)+i)
if len(b2) == 1:
b2 = '0'+b2
t = a+':'+b2+':'+c
write(date, t, 'test', True, '.mp3', 1)
if __name__ == '__main__':
cmdline()