Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/local/bin/python3
import requests
import shlex
import subprocess
# login to beeminder and visit https://www.beeminder.com/api/v1/auth_token.json
auth_token = 'token'
username = 'username'
goal = 'thesis'
url = 'https://www.beeminder.com/api/v1/users/{}/goals/{}/datapoints.json'.format(username, goal)
commit = subprocess.check_output(shlex.split('git log -1 --format="%H"')).strip().decode('UTF-8')
cmd = "git show --numstat {} | grep tex | awk '{{sum+=$1+$2}} END {{print sum;}}'"
lines = int(subprocess.check_output(cmd.format(commit), shell=True))
comment = subprocess.check_output(shlex.split("git log -1 --format=%B")).strip().decode('UTF-8')
if lines > 0:
payload = {
"value": lines,
"comment": comment,
"requestid": commit,
"auth_token": auth_token
}
r = requests.post(url, data=payload)
print('updated beeminder with {} changed lines'.format(lines))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.