Add Beeminder support

This commit is contained in:
Filip Gralinski 2022-01-22 12:34:26 +01:00
parent f58bff3ff4
commit 350daf1615
5 changed files with 49 additions and 1 deletions

View File

@ -15,5 +15,6 @@
"discipline": "none",
"specialization": "none",
"supervisor": "none",
"album_no": "none"
"album_no": "none",
"beeminder_support": "no"
}

View File

@ -135,6 +135,10 @@ if [ "{{ cookiecutter.extra_locale }}" = "pl_PL" -o "{{ cookiecutter.locale }}"
cp -r _optional_files/_pl_files/* .
fi
if [ "{{ cookiecutter.beeminder_support }}" = "yes" ]; then
cp -r _optional_files/_beeminder_support/* .
fi
rm -rf _latex-templates _optional_files
if [ -e .git ]; then

View File

@ -16,3 +16,4 @@ default_context:
specialization: '{{ cookiecutter.specialization }}'
supervisor: '{{ cookiecutter.supervisor }}'
album_no: '{{ cookiecutter.album_no }}'
beeminder: '{{ cookiecuter.beeminder_support }}'

View File

@ -49,6 +49,11 @@ stats.txt: $(PAPER_ID).pdf helpers/stats.sh
bash helpers/stats.sh $< > $@
cat $@
{% if cookiecutter.beeminder_support == 'yes' %}
logbeeminder: helpers/logbeeminder.py stats.txt
python3 $<
{% endif %}
$(PAPER_ID).pdf: $(PAPER_ID).tex preamble.tex metadata.tex $(CONTENT_TEX_SOURCES) bibliography.bib $(SCOREFILES) $(EXTRA_PDFS)
pdflatex $<
bibtex $(PAPER_ID)

View File

@ -0,0 +1,37 @@
#!/usr/bin/env python3
import time
from pyminder.pyminder import Pyminder
import os
import sys
if 'BEEMINDER_USER' not in os.environ:
print('BEEMINDER_USER not set', file=sys.stderr)
exit(1)
if 'BEEMINDER_TOKEN' not in os.environ:
print('BEEMINDER_TOKEN not set', file=sys.stderr)
exit(1)
beeminder_user = os.environ['BEEMINDER_USER']
beeminder_token = os.environ['BEEMINDER_TOKEN']
pyminder = Pyminder(user=beeminder_user, token=beeminder_token)
goal = pyminder.get_goal('{{cookiecutter.paper_id}}')
with open('stats.txt', 'r') as stats_fh:
next(stats_fh)
stats = next(stats_fh)
page_count, _, _ = stats.split('\t')
print(f'reporting {page_count} pages', file=sys.stderr)
now = time.time()
goal.stage_datapoint(value=page_count,
time=now)
goal.commit_datapoints()