Created
August 16, 2012 13:43
-
-
Save chadwhitacre/3370171 to your computer and use it in GitHub Desktop.
Script used to wire up balanced_card_uri migrated from Stripe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!./env/bin/python | |
import csv | |
import sys | |
from gittip import billing, wireup | |
db = wireup.db() | |
wireup.billing() | |
for row in csv.reader(open(sys.argv[1])): | |
participant_id, balanced_card_uri = row | |
participant_id = participant_id.decode('ASCII') | |
balanced_card_uri = balanced_card_uri.decode('ASCII') | |
rec = db.fetchone("SELECT id, balanced_account_uri, last_bill_result " | |
"FROM participants " | |
"WHERE id=%s", (participant_id,)) | |
if rec is None: | |
print "Participant not in db: %s" % participant_id | |
else: | |
balanced_account_uri = rec['balanced_account_uri'] | |
if balanced_account_uri is not None: | |
print participant_id.ljust(16) \ | |
, "already migrated" | |
elif balanced_card_uri == "": | |
print participant_id.ljust(16) \ | |
, "has no balanced_card_uri".ljust(72) \ | |
, rec['last_bill_result'] | |
else: | |
print participant_id.ljust(16) \ | |
, balanced_card_uri.ljust(72) \ | |
, rec['last_bill_result'] | |
billing.associate( participant_id | |
, rec['balanced_account_uri'] | |
, balanced_card_uri | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment