-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdispense_add.py
executable file
·57 lines (40 loc) · 1.47 KB
/
dispense_add.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
#!/usr/bin/env python
import subprocess as sp
while True:
username=None
while(not(username)):
username = raw_input("Username: ")
try:
sp.check_call(["dispense","acct", username])
#sp.check_call(["id", username])
#sp.check_call(["finger", username])
except sp.CalledProcessError:
username = None
continue #Restart the loop
amount=None
int_amount = None
while(not amount):
try:
int_amount = int(raw_input("Amount (in cents): "))
amount = "+"+str(int_amount)
except ValueError:
print "Please enter a number."
amount = None
continue
print "Adding: $%2.2f" % (int_amount/100.0)
reason = raw_input('Reason/Bag Number (Enter just a digit, to say "money in safe. Bag number <input>"): ')
if reason.isdigit():
reason = "Money in safe. Bag number " + reason
elif len(reason)==0:
reason = "Money in safe."
cmd =" ".join(['dispense acct ',username, amount,' "' + reason+'"'])
print "Will call: " + cmd
confirm = raw_input("Correct (Y/N): ").lower()
if confirm and confirm[0]=='n':
#Restart
continue
else:
break
#subprocess call hastes me for not useing speratre args
sp.call(["dispense", "acct", username, amount, reason])
print "Thankyou please remember to do what ever crazy plan the treasurer wants done with the safe today."