Old uncommited changes, restock from cli, "cleanup bounty" feature

This commit is contained in:
Mrkva 2015-07-01 01:06:59 +02:00
parent 84881dece3
commit 934873c2fc
6 changed files with 51 additions and 2 deletions

6
brmbar3/alert.sh Normal file
View file

@ -0,0 +1,6 @@
#!/bin/sh
if [ "$1" = "alert" ]; then
mplayer ~/trombone.wav &
else
mplayer ~/much.wav &
fi

View file

@ -17,6 +17,7 @@ Usage: brmbar-cli.py COMMAND ARGS...
changecredit USER +-AMT
sellitem USER ITEM +-AMT
You can use negative AMT to undo a sale.
restock ITEM AMT
userinfo USER
iteminfo ITEM
@ -199,6 +200,14 @@ elif sys.argv[1] == "consolidate":
print ("Invalid number of parameters, check your parameters.")
else:
shop.consolidate()
elif sys.argv[1] == "restock":
if (len(sys.argv) != 4):
print ("Invalid number of parameters, check your parameters.")
else:
iacct = load_item(sys.argv[2])
amt = int(sys.argv[3])
cash = shop.buy_for_cash(iacct, amt);
print("Old amount {}, increased by {}, take {} from cashbox".format(iacct.balance(), amt, cash))
else:

View file

@ -43,4 +43,14 @@ Item {
loadPage("Management")
}
}
BarButton {
x: 65
y: 438
width: 1150
text: "* Mroze a Termixy najdes v lednici *"
}
}

View file

@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/python
import sys

6
brmbar3/uklid-refill.sh Normal file
View file

@ -0,0 +1,6 @@
#!/bin/bash
if [ `./brmbar-cli.py iteminfo uklid|grep -o '[0-9]*.[0-9]* pcs'|cut -d '.' -f 1` -eq 0 ]; then
BOUNTY=`./brmbar-cli.py restock uklid 1 | grep -o 'take -[0-9]*'|grep -o '[0-9]*'`
echo "Brmlab cleanup bounty for ${BOUNTY}CZK!!!"|ssh jenda@fry.hrach.eu
fi

18
brmbar3/uklid-watchdog.sh Normal file
View file

@ -0,0 +1,18 @@
#!/bin/bash
LASTIDF=/home/brmlab/uklid.last
LASTID=`cat $LASTIDF 2>/dev/null || echo 0`
RES=`psql brmbar -Atq -c "select id,description from transactions where id>$LASTID and description like 'BrmBar sale of 1x uklid%' LIMIT 1;"`
if [ ! -z "$RES" ]; then
LASTID=`echo "$RES"|cut -d '|' -f 1`
echo $LASTID > $LASTIDF
WINNER=`echo "$RES"|grep -o 'to [^ ]*'|cut -d ' ' -f 2`
if [ -z "$WINNER" ]; then
WINNER="anonymous hunter"
fi
echo "Brmlab cleanup bounty was claimed by $WINNER! Thanks!"|ssh jenda@fry.hrach.eu
fi