tuvotereminder.py 624 Bytes
Newer Older
1
#!/usr/bin/env python3
2
3
4
5

import subprocess
import time

Lukas Fleischer's avatar
Lukas Fleischer committed
6
7
import aurweb.config
import aurweb.db
8

Lukas Fleischer's avatar
Lukas Fleischer committed
9
notify_cmd = aurweb.config.get('notifications', 'notify-cmd')
10
11


12
def main():
Lukas Fleischer's avatar
Lukas Fleischer committed
13
    conn = aurweb.db.Connection()
14

15
16
17
    now = int(time.time())
    filter_from = now + 500
    filter_to = now + 172800
18

Lukas Fleischer's avatar
Lukas Fleischer committed
19
20
21
    cur = conn.execute("SELECT ID FROM TU_VoteInfo " +
                       "WHERE End >= ? AND End <= ?",
                       [filter_from, filter_to])
22
23

    for vote_id in [row[0] for row in cur.fetchall()]:
24
        subprocess.Popen((notify_cmd, 'tu-vote-reminder', str(vote_id))).wait()
25
26
27
28


if __name__ == '__main__':
    main()