Modify

Opened 6 years ago

Closed 6 years ago

#13492 closed defect (fixed)

error: UID command error: BAD ['Error in IMAP command UID SEARCH: Invalid search date parameter

Reported by: anonymous Owned by: lucid
Priority: normal Component: MailArchivePlugin
Severity: normal Keywords:
Cc: Trac Release:

Description

2018-10-16 15:00:03,476 Trac[console] ERROR: Exception in trac-admin command: u"mailarchive fetch 'imap.example.com 'archive@example.com' EXAMPLE
Traceback (most recent call last):
  File "build\bdist.win32\egg\trac\admin\console.py", line 83, in onecmd
    rv = cmd.Cmd.onecmd(self, line) or 0
  File "C:\Python27\Lib\cmd.py", line 220, in onecmd
    return self.default(line)
  File "build\bdist.win32\egg\trac\admin\console.py", line 252, in default
    return self.cmd_mgr.execute_command(*args)
  File "build\bdist.win32\egg\trac\admin\api.py", line 135, in execute_command
    return f(*fargs)
  File "build\bdist.win32\egg\mailarchive\admin.py", line 34, in _do_fetch
    typ, data = imap_conn.uid('search', None, '(OR UNSEEN (SINCE %s))' % (yesterday,))
  File "C:\Python27\Lib\imaplib.py", line 772, in uid
    typ, dat = self._simple_command(name, command, *args)
  File "C:\Python27\Lib\imaplib.py", line 1087, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "C:\Python27\Lib\imaplib.py", line 917, in _command_complete
    raise self.error('%s command error: %s %s' % (name, typ, data))
error: UID command error: BAD ['Error in IMAP command UID SEARCH: Invalid search date parameter (0.001 + 0.000 secs).']

Attachments (0)

Change History (7)

comment:1 Changed 6 years ago by anonymous

I get this since 2018-10-02 00:00. Before that it worked.

comment:2 Changed 6 years ago by anonymous

Somehow the locale must have changed and it's not creating a localized yesterday value.

comment:3 Changed 6 years ago by Jun Omae

The issue seems to be caused by %b in strftime with non-English locale.

Also, I noticed another issue which exception_to_unicode and _ are not imported.

  • mailarchiveplugin/trunk/mailarchive/admin.py

    diff --git a/mailarchiveplugin/trunk/mailarchive/admin.py b/mailarchiveplugin/trunk/mailarchive/admin.py
    index c93d43e36..fd76fe77e 100644
    a b import os 
    66
    77from trac.admin import IAdminCommandProvider
    88from trac.attachment import Attachment
     9from trac.core import Component, TracError, implements
    910from trac.db.api import DatabaseManager
    10 from trac.core import *
    1111from trac.env import IEnvironmentSetupParticipant
     12from trac.util.text import exception_to_unicode
     13from trac.util.translation import _
    1214
    1315from mailarchive.model import ArchivedMail, SCHEMA, normalized_filename
    1416
    class MailArchiveAdmin(Component): 
    3537        imap_conn.select()
    3638
    3739        # Search for mails since yesterday
    38         yesterday = (datetime.date.today() - datetime.timedelta(1)).strftime("%d-%b-%Y")
    39         typ, data = imap_conn.uid('search', None, '(OR UNSEEN (SINCE %s))' % (yesterday,))
     40        yesterday = _imap_date_text(datetime.date.today() -
     41                                    datetime.timedelta(1))
     42        typ, data = imap_conn.uid('search', None,
     43                                  '(OR UNSEEN (SINCE %s))' % yesterday)
    4044        for uid in data[0].split():
    4145
    4246            # No duplicates
    class MailArchiveAdmin(Component): 
    122126            dbm.set_database_version(PLUGIN_VERSION, PLUGIN_NAME)
    123127        else:
    124128            dbm.upgrade(PLUGIN_VERSION, PLUGIN_NAME, 'mailarchive.upgrades')
     129
     130
     131def _imap_date_text(dt):
     132    months = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
     133              'Oct', 'Nov', 'Dec')
     134    return '%02d-%s-%04d' % (dt.day, months[dt.month - 1], dt.year)

comment:4 Changed 6 years ago by lucid

In 17291:

MailArchivePlugin: Always use IMAP RFC compatible month names, independent of locale.
(see #13492)

comment:5 in reply to:  3 Changed 6 years ago by lucid

Replying to Jun Omae:

The issue seems to be caused by %b in strftime with non-English locale.

Oh, I didn't notice your patch. It looks like we came to similar conclusions.

Also, I noticed another issue which exception_to_unicode and _ are not imported.

Thank you, I will fix it.

comment:6 Changed 6 years ago by lucid

In 17292:

MailArchivePlugin: Fix imports.
(see #13492)

comment:7 Changed 6 years ago by lucid

Resolution: fixed
Status: newclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain lucid.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.