summaryrefslogtreecommitdiffstats
path: root/scripts/tuvotereminder.py
blob: 97b1d12e72417f8241cb11c32a87e1f753fcc594 (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
#!/usr/bin/python3

import subprocess
import time

import aurweb.config
import aurweb.db

notify_cmd = aurweb.config.get('notifications', 'notify-cmd')


def main():
    conn = aurweb.db.Connection()

    now = int(time.time())
    filter_from = now + 500
    filter_to = now + 172800

    cur = conn.execute("SELECT ID FROM TU_VoteInfo " +
                       "WHERE End >= ? AND End <= ?",
                       [filter_from, filter_to])

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


if __name__ == '__main__':
    main()