jp00p / AGIMUS

Discord bot for Friends of Desoto
MIT License
10 stars 9 forks source link

Bug: When parent directory doesn't exist, the report is not generated #398

Closed mathew-fleisch closed 1 year ago

mathew-fleisch commented 1 year ago
2023-03-13 12:06:12,276 - Traceback (most recent call last):
  File "/bot/commands/reports.py", line 70, in reports
    response = generate_diagnostic_card(report_style)
  File "/bot/commands/reports.py", line 226, in generate_diagnostic_card
    return generate_report_card(title, description, table, type, intro_data)
  File "/bot/commands/reports.py", line 373, in generate_report_card
    base_image.save("./images/reports/report.png")
  File "/home/bot/.local/lib/python3.8/site-packages/PIL/Image.py", line 2232, in save
    fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: './images/reports/report.png'

Manually creating the parent directory allowed the report to be generated

mkdir /bot/images/reports

This line should instead create the directory structure, before attempting to save a file in that directory: https://github.com/jp00p/AGIMUS/blob/2b4a0ffa611f18d177c4a208e92d556ee4c38100/commands/reports.py#L373