-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (29 loc) · 1.02 KB
/
main.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
#!/usr/bin/env python
from sys import argv, exit
import functions as f
if len(argv) != 2:
print 'usage: %s <upc>' % argv[0]
exit(-1)
upc = argv[1]
f.log(upc)
if upc[0] == '4':
if upc[6] == '1':
# user ID card scanned
f.update_user(int(upc[-5:-1]))
if upc[6] == '2':
# nullary command functions
cmd_id = int(upc[-5:-1])
if cmd_id == 1:
from subprocess import call
call(['git', 'pull'])
elif upc[0] in [str(i) for i in [0,1,6,7,8]]:
user = f.get_user()
username = (('.@' + user.twitter_handle if user.twitter_handle
else user.name) if user
else 'Somebody')
beveragename = f.get_beverage_description(upc)
print 'beveragename: ', beveragename
if not beveragename: beveragename = 'something'
f.twitter_post('%s grabbed a %s' % (username, beveragename))
else:
print 'don\'t know what that is'