diff --git a/build-deb/donationcalc/DEBIAN/postinst b/build-deb/donationcalc/DEBIAN/postinst index 4c88396..292ce1e 100755 --- a/build-deb/donationcalc/DEBIAN/postinst +++ b/build-deb/donationcalc/DEBIAN/postinst @@ -2,7 +2,7 @@ /usr/bin/echo "Adding monthly rebalance to crontab" /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/rm /tmp/donationcalccrontab.tmp /usr/bin/systemctl enable donationcalc.service diff --git a/build-deb/donationcalc/DEBIAN/prerm b/build-deb/donationcalc/DEBIAN/prerm index 1f6fd6b..6c62496 100755 --- a/build-deb/donationcalc/DEBIAN/prerm +++ b/build-deb/donationcalc/DEBIAN/prerm @@ -2,7 +2,7 @@ /usr/bin/echo "Removing monthly rebalance to crontab" /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/rm /tmp/donationcalccrontab.tmp /tmp/donationcalccrontab.tmp1 /sbin/service donationcalc stop diff --git a/rebalance.py b/rebalance.py new file mode 100755 index 0000000..723e28b --- /dev/null +++ b/rebalance.py @@ -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) diff --git a/run.py b/run.py index edb5892..723e28b 100755 --- a/run.py +++ b/run.py @@ -1,31 +1,16 @@ -from donationcalc import app from donationcalc import donationconfig 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() +donconf = donationconfig.donationconfig() +donconf.rebalance() +sender = donationcalc.models.sender() +donors = [] +f = open("donors.txt", "r") -parser = argparse.ArgumentParser() -args = parseArgs(parser) +for line in f.readlines(): + linesplit = line.split(",") + newdonor = donationcalc.models.donor(email = linesplit[0], monthly = linesplit[1]) + donors.append(newdonor) +f.close() -if __name__ == '__main__': - - if args.rebalance: - 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) - exit() - - app.run(debug=False) +donationcalc.models.rebalanceall(sender,donors)