Skip to content

Instantly share code, notes, and snippets.

@chadwhitacre
Created August 16, 2012 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadwhitacre/3370171 to your computer and use it in GitHub Desktop.
Save chadwhitacre/3370171 to your computer and use it in GitHub Desktop.
Script used to wire up balanced_card_uri migrated from Stripe
#!./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