blob: c9de12233a62abab88ad8a179405263ab70f40fe (
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
|
#!/usr/bin/env python3
import json
from os import environ
import sys
import os
# krebs polling
import poll
f = 'suggestions.json'
db = poll.load_db(f)
votes = []
try:
votes = sys.argv[1:]
except:
print("""usage: up number (...)
upvotes one or more entries based on .list""")
sys.exit(1)
voter = environ['_prefix']
for vote in votes:
try:
vote = int(vote)
db[vote]['votes'][voter] = 1
except:
print("voting for #%s failed" %vote)
print("Thanks for your votes %s"%environ['_from'])
poll.save_db(f,db)
|