summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-example.yaml7
-rw-r--r--imggen.py3
-rw-r--r--main.py14
3 files changed, 15 insertions, 9 deletions
diff --git a/config-example.yaml b/config-example.yaml
new file mode 100644
index 0000000..6367635
--- /dev/null
+++ b/config-example.yaml
@@ -0,0 +1,7 @@
+tito:
+ mac_token:
+
+printer:
+ maj:
+ min:
+
diff --git a/imggen.py b/imggen.py
index cdc6314..460b432 100644
--- a/imggen.py
+++ b/imggen.py
@@ -1,6 +1,5 @@
from PIL import Image, ImageDraw, ImageFont
import math
-import printer
font_bold = ImageFont.truetype("/usr/share/fonts/TTF/IosevkaSS08-Bold.ttc", 70, encoding="unic")
font_norm = ImageFont.truetype("/usr/share/fonts/TTF/IosevkaSS08-Regular.ttc", 40, encoding="unic")
@@ -17,7 +16,7 @@ def name(name: str):
draw = ImageDraw.Draw(img)
draw.text((0, 0), name, font=font_bold, fill="black")
- if font_bold.getlength(name) > MAX_WIDTH:
+ if txt_len > MAX_WIDTH:
wpercent = (MAX_WIDTH / float(img.size[0]))
hsize = int((float(img.size[1]) * float(wpercent)))
img = img.resize((MAX_WIDTH, hsize), Image.Resampling.LANCZOS)
diff --git a/main.py b/main.py
index d4c5149..2648460 100644
--- a/main.py
+++ b/main.py
@@ -56,14 +56,15 @@ async def create_checkin(request: Request):
pizza_pref = list(filter(lambda a: a['question'] == 'What is your pizza preference?', content['answers']))
if len(pizza_pref) == 0:
- return "ok"
+ return Response(status_code=204)
+
+ d_reqs = None
+ q_d_reqs = list(filter(lambda a: a['question'] == 'Do you have any dietary restrictions?', content['answers']))
+ if len(q_d_reqs) > 0:
+ d_reqs = q_d_reqs[0]['response']
- d_reqs = list(filter(lambda a: a['question'] == 'Do you have any dietary restrictions?', content['answers']))
logger.info(f"Printing food token for {attendee_name}...")
- if len(d_reqs) == 0:
- printer.print_food(attendee_name, pizza_pref[0]['response'], str(group), None)
- else:
- printer.print_food(attendee_name, pizza_pref[0]['response'], str(group), d_reqs[0]['response'])
+ printer.print_food(attendee_name, pizza_pref[0]['response'], str(group), d_reqs)
serial = serial + 1
if serial % 10 == 0:
@@ -73,7 +74,6 @@ async def create_checkin(request: Request):
return Response(status_code=204)
finally:
lock.release()
-
if __name__ == '__main__':
uvicorn.run(app, log_level="info", host="0.0.0.0", port=3000)