|
|
|
@ -6,7 +6,9 @@ from fosspay.email import send_thank_you, send_declined |
|
|
|
|
|
|
|
|
|
from datetime import datetime, timedelta |
|
|
|
|
|
|
|
|
|
import requests |
|
|
|
|
import stripe |
|
|
|
|
import subprocess |
|
|
|
|
|
|
|
|
|
stripe.api_key = _cfg("stripe-secret") |
|
|
|
|
|
|
|
|
@ -45,4 +47,30 @@ for donation in donations: |
|
|
|
|
else: |
|
|
|
|
print("Skipping {}".format(donation)) |
|
|
|
|
|
|
|
|
|
print("Done. {} records processed.".format(len(donations))) |
|
|
|
|
print("{} records processed.".format(len(donations))) |
|
|
|
|
|
|
|
|
|
if _cfg("patreon-refresh-token"): |
|
|
|
|
print("Updating Patreon API token") |
|
|
|
|
|
|
|
|
|
r = requests.post('https://www.patreon.com/api/oauth2/token', params={ |
|
|
|
|
'grant_type': 'refresh_token', |
|
|
|
|
'refresh_token': _cfg("patreon-refresh-token"), |
|
|
|
|
'client_id': _cfg("patreon-client-id"), |
|
|
|
|
'client_secret': _cfg("patreon-client-secret") |
|
|
|
|
}) |
|
|
|
|
if r.status_code != 200: |
|
|
|
|
print("Failed to update Patreon API token") |
|
|
|
|
sys.exit(1) |
|
|
|
|
resp = r.json() |
|
|
|
|
with open("config.ini") as f: |
|
|
|
|
config = f.read() |
|
|
|
|
config = config.replace(_cfg("patreon-access-token"), resp["access_token"]) |
|
|
|
|
config = config.replace(_cfg("patreon-refresh-token"), resp["refresh_token"]) |
|
|
|
|
with open("config.ini", "w") as f: |
|
|
|
|
f.write(config) |
|
|
|
|
print("Refreshed Patreon API token") |
|
|
|
|
reload_cmd = _cfg("reload-command") |
|
|
|
|
if not reload_cmd: |
|
|
|
|
print("Cannot reload application, add reload-command to config.ini") |
|
|
|
|
else: |
|
|
|
|
subprocess.run(reload_cmd, shell=True, check=True) |
|
|
|
|