TypeError in email.send_notification
In commit fd33e5cb, the import
command logs a number of errors that don’t appear fatal, but then ends with:
Traceback (most recent call last):
File "/usr/alwaysdata/python/3.9.2/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/alwaysdata/python/3.9.2/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/user/Flatisfy/flatisfy/__main__.py", line 200, in <module>
main()
File "/home/user/Flatisfy/flatisfy/__main__.py", line 186, in main
cmds.import_and_filter(config, load_from_db=False, new_only=args.new_only)
File "/home/user/Flatisfy/flatisfy/cmds.py", line 209, in import_and_filter
email.send_notification(config, new_flats)
File "/home/user/Flatisfy/flatisfy/email.py", line 100, in send_notification
area = str(int(flat.area))
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'
After this the web interface shows "Last update: 51 years ago" and "No available flats."
This patch seems to allow going past that error:
diff --git a/flatisfy/email.py b/flatisfy/email.py
index 8fceb4c..d473eaa 100644
--- a/flatisfy/email.py
+++ b/flatisfy/email.py
@@ -97,8 +97,8 @@ def send_notification(config, flats):
for flat in flats:
title = str(flat.title)
flat_id = str(flat.id)
- area = str(int(flat.area))
- cost = int(flat.cost)
+ area = str(int(flat.area or 0))
+ cost = int(flat.cost or 0)
currency = str(flat.currency)
txt += f"- {title}: {website_url}#/flat/{flat_id} "