Weekly status run fails after update from v67 to v68

I suspect that there is something fishy in my log files.

This is the error, same error that I got today morning via email.

root@box:~# /root/mailinabox/management/mail_log.py
Scanning logs from 2024-04-08 00:00:00 to 2024-04-08 16:59:44
174964 Log lines scanned, 2150 lines parsed in 1.81 seconds


Received email
══════════════ 

Traceback (most recent call last):
  File "/root/mailinabox/management/mail_log.py", line 869, in <module>
    scan_mail_log(env_vars)
  File "/root/mailinabox/management/mail_log.py", line 181, in scan_mail_log
    print_user_table(
  File "/root/mailinabox/management/mail_log.py", line 682, in print_user_table
    if None not in {latest, earliest}:
TypeError: unhashable type: 'list'
root@box:~# 

Any ideas why this happens or how to fix it are appreciated.

I think someone already proposed a fix.

1 Like

Thank you @KiekerJan.

I can confirm that fix works,
I edited the file using text editor, just FYI doing this might cause an issue when updating MIAB next time.

Same here. Would a manual change of this cause a later update to break?

@xxfogs IMHO yes, but this is what I’ve done before editing the file in question, create a backup of the file I’m going to modify before modifying the file in question.

cp -pi mailinabox/management/mail_log.py mailinabox/management/mail_log.py.orig

If setup.sh fails, just copy or move the original file over the modifed and rerun setup.sh

How to copy:

cp -pi mailinabox/management/mail_log.py.orig mailinabox/management/mail_log.py

Which will ask you for confirmation before overwriting target file.

How to move:

mv -i mailinabox/management/mail_log.py.orig mailinabox/management/mail_log.py

Which will also ask you for confirmation before overwriting target file.

Or the more brutal method, if there is nothing else to do, destroy the “mailinabox” directory recursively, e.g. all the files and directories in “mailinabox” and “mailinabox” directory it self, and rerun setup.sh.

Keep the same file extension when creating backup files, so you can find the files you’ve modified:

How to find files that have ‘.orig’ extension

find mailinabox/ -type f -name '*.orig' -print

Output of the find command in my case:

mailinabox/management/mail_log.py.orig

And you can also see what changes you’ve made:

diff -u mailinabox/management/mail_log.py.orig mailinabox/management/mail_log.py

Output of the diff command:

--- mailinabox/management/mail_log.py.orig	2024-04-02 08:39:21.613010269 +0300
+++ mailinabox/management/mail_log.py	2024-04-10 21:59:20.023801981 +0300
@@ -679,7 +679,7 @@
                 data_accum[col] += d[row]
 
         try:
-            if None not in {latest, earliest}:
+            if None not in [latest, earliest]: # noqa PLR6201
                 vert_pos = len(line)
                 e = earliest[row]
                 l = latest[row]
@@ -732,7 +732,7 @@
         else:
             header += l.rjust(max(5, len(l) + 1, col_widths[col]))
 
-    if None not in {latest, earliest}:
+    if None not in [latest, earliest]: # noqa PLR6201
         header += " │ timespan   "
 
     lines.insert(0, header.rstrip())
@@ -757,7 +757,7 @@
         footer += temp.format(data_accum[row])
 
     try:
-        if None not in {latest, earliest}:
+        if None not in [latest, earliest]: # noqa PLR6201
             max_l = max(latest)
             min_e = min(earliest)
             timespan = relativedelta(max_l, min_e)

Would make sense if it did, but I wonder if the maintainer has something special to say. Thanks for these instructions though!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.