except IOError: for i in range(5): print "YOU ARE RUNNING THE STOCK CONFIG, which is not in git, smtp passwords and so on, ask jef for fr1ckets_priv.conf" app.config.from_pyfile('fr1ckets.conf') print len(sys.argv) print sys.argv if len(sys.argv) < 4: print "usage: {0} how_many discount_in_eur reason".format(sys.argv[0]) sys.exit(1) N_VOUCHERS = int(sys.argv[1]) DISCOUNT = int(sys.argv[2]) REASON = " ".join(sys.argv[3:]) with app.app_context(): setup.setup_db() d = { 'discount': DISCOUNT, 'claimed': False, 'claimed_at': None, 'comments': 'generated by script', 'reason': REASON, } for i in range(N_VOUCHERS): code = model.voucher_create(g.db_cursor, d) print code g.db_commit = True setup.wrapup_db(None)
import pprint import os try: app.config.from_pyfile('fr1ckets_priv.conf') app.debug = True app.secret_key = app.config['SECRET_KEY'] except IOError: for i in range(5): print "YOU ARE RUNNING THE STOCK CONFIG, which is not in git, smtp passwords and so on, ask jef for fr1ckets_priv.conf" app.config.from_pyfile('fr1ckets.conf') if not len(sys.argv) == 2: print "usage: {0} filename".format(sys.argv[0]) with app.app_context(): setup.setup_db() products_all = model.products_get(g.db_cursor) def find_product(name): for r in products_all: if r['name'] == name: return r return None with open(sys.argv[1], 'rb') as csvfile: r = csv.DictReader(csvfile, fieldnames=[ 'email', 'name', 'dob', 'vegitarian', 'when' ]) persons = 0 emails = {} for row in r: if row['email'] not in emails: