invalid literal for int() with base 10 (Mailbox does not exist)

Issue #1252 closed
EB created an issue

I’ve added a mailbox to import through the gui and ran import.sh.
After some time I receive the following error:

root@piler:/usr/libexec/piler# /usr/libexec/piler/import.sh
/var/piler/imap /etc/data
/var/piler/imap /var/piler/imap
Traceback (most recent call last):
  File "/usr/libexec/piler/imapfetch.py", line 193, in <module>
    main()
  File "/usr/libexec/piler/imapfetch.py", line 177, in main
    process_folder(conn, folder)
  File "/usr/libexec/piler/imapfetch.py", line 65, in process_folder
    n = int(data[0])
ValueError: invalid literal for int() with base 10: b"Mailbox doesn't exist: INBOX/_Test (0.001 + 0.000 secs)."

A mailbox without any folders does not throw this error. Seeing no one else ran into this made me think it has something to do with the underscore. So I excluded this folder and then ran into the same issue with a folder with an exclamation mark (INBOX/!Temp).
How can I make this work without having to rename each and every folder?

Comments (6)

  1. EB reporter

    Apparently this is caused by special characters in the foldernames (i.e. !, & and _).
    How can this script be modified (if at all) to work with these chars in the foldernames?

  2. Janos SUTO repo owner

    Can you create a test imap account for me with such folder names? If so, send me the login details to my email (Run piler -V to see it). A few spam emails would be fine in the mailbox.

  3. EB reporter

    I don’t know any python, but added the below lines and that made it work (or at least it fetches the folders and contents).

       if '!' in folder:
           n = data[0]
           n = int(n)
        elif '_' in folder:
           n = data[0]
           n = int(n)
        elif '&' in folder:
           n = data[0]
           n = int(n)
        else:
           n = int(data[0])
    

    I put that instead of the line “n = int(data[0])”
    Now it seems to crash on other things… Not sure if it is specific mails/folders or the amount of mails/folders….
    Looking into this at the moment….

  4. Log in to comment