Modify ↓
      
        Opened 7 years ago
Closed 7 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 7 years ago by
comment:2 Changed 7 years ago by
Somehow the locale must have changed and it's not creating a localized yesterday value.
comment:3 follow-up: 5 Changed 7 years ago by
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.pydiff --git a/mailarchiveplugin/trunk/mailarchive/admin.py b/mailarchiveplugin/trunk/mailarchive/admin.py index c93d43e36..fd76fe77e 100644 a b import os 6 6 7 7 from trac.admin import IAdminCommandProvider 8 8 from trac.attachment import Attachment 9 from trac.core import Component, TracError, implements 9 10 from trac.db.api import DatabaseManager 10 from trac.core import *11 11 from trac.env import IEnvironmentSetupParticipant 12 from trac.util.text import exception_to_unicode 13 from trac.util.translation import _ 12 14 13 15 from mailarchive.model import ArchivedMail, SCHEMA, normalized_filename 14 16 … … class MailArchiveAdmin(Component): 35 37 imap_conn.select() 36 38 37 39 # 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) 40 44 for uid in data[0].split(): 41 45 42 46 # No duplicates … … class MailArchiveAdmin(Component): 122 126 dbm.set_database_version(PLUGIN_VERSION, PLUGIN_NAME) 123 127 else: 124 128 dbm.upgrade(PLUGIN_VERSION, PLUGIN_NAME, 'mailarchive.upgrades') 129 130 131 def _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:5 Changed 7 years ago by
Replying to Jun Omae:
The issue seems to be caused by
%binstrftimewith 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_unicodeand_are not imported.
Thank you, I will fix it.
comment:7 Changed 7 years ago by
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
Note: See
        TracTickets for help on using
        tickets.
    


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