forked from fram3d/donationcalc
fix issue with arguments and gunicorn
This commit is contained in:
parent
96c3ae4066
commit
2e46574c22
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/usr/bin/echo "Adding monthly rebalance to crontab"
|
/usr/bin/echo "Adding monthly rebalance to crontab"
|
||||||
/usr/bin/crontab -l > /tmp/donationcalccrontab.tmp
|
/usr/bin/crontab -l > /tmp/donationcalccrontab.tmp
|
||||||
/usr/bin/echo "0 0 1 * * /usr/bin/python3 /var/donationcalc/run.py -r" >> /tmp/donationcalccrontab.tmp
|
/usr/bin/echo "0 0 1 * * /usr/bin/python3 /var/donationcalc/rebalance.py" >> /tmp/donationcalccrontab.tmp
|
||||||
/usr/bin/crontab /tmp/donationcalccrontab.tmp
|
/usr/bin/crontab /tmp/donationcalccrontab.tmp
|
||||||
/usr/bin/rm /tmp/donationcalccrontab.tmp
|
/usr/bin/rm /tmp/donationcalccrontab.tmp
|
||||||
/usr/bin/systemctl enable donationcalc.service
|
/usr/bin/systemctl enable donationcalc.service
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/usr/bin/echo "Removing monthly rebalance to crontab"
|
/usr/bin/echo "Removing monthly rebalance to crontab"
|
||||||
/usr/bin/crontab -l > /tmp/donationcalccrontab.tmp
|
/usr/bin/crontab -l > /tmp/donationcalccrontab.tmp
|
||||||
/usr/bin/grep -v "0 0 1 * * /usr/bin/python3 /var/donationcalc/run.py -r" /tmp/donationcalccrontab.tmp >> /tmp/donationcalccrontab.tmp1
|
/usr/bin/grep -v "0 0 1 * * /usr/bin/python3 /var/donationcalc/rebalance.py" /tmp/donationcalccrontab.tmp >> /tmp/donationcalccrontab.tmp1
|
||||||
/usr/bin/crontab /tmp/donationcalccrontab.tmp1
|
/usr/bin/crontab /tmp/donationcalccrontab.tmp1
|
||||||
/usr/bin/rm /tmp/donationcalccrontab.tmp /tmp/donationcalccrontab.tmp1
|
/usr/bin/rm /tmp/donationcalccrontab.tmp /tmp/donationcalccrontab.tmp1
|
||||||
/sbin/service donationcalc stop
|
/sbin/service donationcalc stop
|
||||||
|
16
rebalance.py
Executable file
16
rebalance.py
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
from donationcalc import donationconfig
|
||||||
|
import donationcalc.models
|
||||||
|
|
||||||
|
donconf = donationconfig.donationconfig()
|
||||||
|
donconf.rebalance()
|
||||||
|
sender = donationcalc.models.sender()
|
||||||
|
donors = []
|
||||||
|
f = open("donors.txt", "r")
|
||||||
|
|
||||||
|
for line in f.readlines():
|
||||||
|
linesplit = line.split(",")
|
||||||
|
newdonor = donationcalc.models.donor(email = linesplit[0], monthly = linesplit[1])
|
||||||
|
donors.append(newdonor)
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
donationcalc.models.rebalanceall(sender,donors)
|
15
run.py
15
run.py
@ -1,18 +1,6 @@
|
|||||||
from donationcalc import app
|
|
||||||
from donationcalc import donationconfig
|
from donationcalc import donationconfig
|
||||||
import donationcalc.models
|
import donationcalc.models
|
||||||
import argparse
|
|
||||||
|
|
||||||
def parseArgs(parser):
|
|
||||||
parser.add_argument("-r", "--rebalance", dest = "rebalance", help = "balance the monthly values", action="store_true")
|
|
||||||
return parser.parse_args()
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
args = parseArgs(parser)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
|
|
||||||
if args.rebalance:
|
|
||||||
donconf = donationconfig.donationconfig()
|
donconf = donationconfig.donationconfig()
|
||||||
donconf.rebalance()
|
donconf.rebalance()
|
||||||
sender = donationcalc.models.sender()
|
sender = donationcalc.models.sender()
|
||||||
@ -26,6 +14,3 @@ if __name__ == '__main__':
|
|||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
donationcalc.models.rebalanceall(sender,donors)
|
donationcalc.models.rebalanceall(sender,donors)
|
||||||
exit()
|
|
||||||
|
|
||||||
app.run(debug=False)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user