Gmail Backup 0.1.2 error: could not parse command

Bug #884342 reported by Saarloop
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Backup Gmail
Fix Committed
Undecided
C Fraire

Bug Description

ubuntu 11.10
Starting the program I get the following error message in the terminal:

Traceback (most recent call last):
  File "/media/data_/Download/Gmail_Backup/backup-gmail/gui.py", line 358, in run
  File "/media/data_/Download/Gmail_Backup/backup-gmail/backup_gmail.py", line 526, in doBackup
  File "/media/data_/Download/Gmail_Backup/backup-gmail/backup_gmail.py", line 351, in backupTo
  File "/media/data_/Download/Gmail_Backup/backup-gmail/backup_gmail.py", line 338, in doBackup
  File "/media/data_/Download/Gmail_Backup/backup-gmail/backup_gmail.py", line 310, in fetchAllMail
  File "/media/data_/Download/Gmail_Backup/backup-gmail/backup_gmail.py", line 299, in fetchAllLabel
  File "/media/data_/Download/Gmail_Backup/backup-gmail/backup_gmail.py", line 209, in fetchMailByLabel
  File "/media/data_/Download/Gmail_Backup/backup-gmail/backup_gmail.py", line 136, in searchByDate
  File "/usr/lib/python2.7/imaplib.py", line 627, in search
    typ, dat = self._simple_command(name, *criteria)
  File "/usr/lib/python2.7/imaplib.py", line 1070, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "/usr/lib/python2.7/imaplib.py", line 905, in _command_complete
    raise self.error('%s command error: %s %s' % (name, typ, data))
error: SEARCH command error: BAD ['Could not parse command']

Tags: backup gmail
Revision history for this message
Saarloop (winfried100) wrote :

Sorry: the version was not 0.1.2 but ...2.1 (latest one)

Revision history for this message
C Fraire (cfraire) wrote :

Winfried, what date arguments are you trying? Version 0.1.2.1 requires strictly US English dd-MMM-yyyy format.

You might look at the branched version at:

    http://bazaar.launchpad.net/~cfraire/backup-gmail/devel/files.

That version uses the system locale to allow non-English values for dd-MMM-yyyy.

Revision history for this message
Saarloop (winfried100) wrote :

Hi Fraire!
Thank you for your comment. I tried the indicated version in your link an got a different error now: "unsupported local setting".

The requested date format in the program window of Backup Gmail is dd-MMM-yyyy. But the abbreviation of 'October' is 'Okt', derivated from the German 'Oktober' and should perhaps be 'Oct'. This could be the reason for the malfunction. But how can I change the right format?

I get now:

File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/gui.py", line 386, in run
    self.gobj.execute()
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 433, in execute
    self.__fetchByLabels(date_range, include_labels, exclude_labels)
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 402, in __fetchByLabels
    self.__fetchMailByLabel(l, date_range)
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 277, in __fetchMailByLabel
    date_range = self.searchByDate(*date_range)
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 159, in searchByDate
    gstart = GmailDate.fromLocal(start)
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 636, in fromLocal
    locale.setlocale(locale.LC_TIME, cls.GMAIL_LOC)
  File "/usr/lib/python2.7/locale.py", line 540, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting

Revision history for this message
C Fraire (cfraire) wrote :

Winfried, would you please try the following change to line 620 in backup_gmail.py. Instead of this:

 GMAIL_LOC = 'en_US'

please use this:

 GMAIL_LOC = 'POSIX'

and see if it runs correctly using 'Okt' for your dd-MMM-yyyy. I had used 'en_US' because I had found documentation stating that this locale was invariably installed regardless of a user's particular locale choice, but this is apparently not the case. Now I see that 'POSIX' should be used for the purpose I had in mind.

Revision history for this message
Saarloop (winfried100) wrote :

Dear CFraire, I followed your last instruction modifying line 620 with always the same error

File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/gui.py", line 386, in run
    self.gobj.execute()
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 433, in execute
    self.__fetchByLabels(date_range, include_labels, exclude_labels)
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 402, in __fetchByLabels
    self.__fetchMailByLabel(l, date_range)
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 277, in __fetchMailByLabel
    date_range = self.searchByDate(*date_range)
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 159, in searchByDate
    gstart = GmailDate.fromLocal(start)
  File "/media/data_/Download/Gmail_Backup_extracted/backup-gmail/backup_gmail.py", line 640, in fromLocal
    locale.setlocale(locale.LC_TIME, currlang)
  File "/usr/lib/python2.7/locale.py", line 540, in setlocale
    return _setlocale(category, locale)
Error: unsupported locale setting

Revision history for this message
C Fraire (cfraire) wrote :

Hi, Winfried. Would you pull the latest from:

    http://bazaar.launchpad.net/~cfraire/backup-gmail/devel/files

Please note there is an additional file, imapUTF7.py, which is newly used to support Gmail folder names with non-ASCII characters.

I updated and tested the date handling with a user account set to a German locale, as well as testing non-English folders.

Revision history for this message
Saarloop (winfried100) wrote :

Hi CFraire,

finally the program is working fine! I thank you very much for your assistance, endurance and efficiency.
You prepared the application for international use now, so that it should get a new release number by this improvement!

With very best regards

Winfried

C Fraire (cfraire)
Changed in backup-gmail:
status: New → Fix Committed
assignee: nobody → C Fraire (cfraire)
Revision history for this message
Saarloop (winfried100) wrote :

I apologizes, but I found a further bug in the backup results.

After the backup has finished, Gui.py is opening a windows indicating the labels and dimension of the different files clearly readable.

Inside the backup folder I found the file names of the backed emails like the following examples:

0ff79da63ee95c2dc562993125a2c68679e11ce43d901c0a7172d8322507b2b7
2c12a4ee0ce88a0ece6f0e693d773b3b5e9eba2c8ee4ef22dccf5335bf46332d
2d62da834446a03dda0885a46e19c24c6885fb7c617fc3c42755ec34d1044c2e
4b8fbc20ba29b824250ca025168f7228ccc35e1942bade5064ef46d4ce5c2186
....... and so on

Therefore you can't search a specific email neither by date nor by subject.

The file headers have suffered because several indications (e.g. references of return address) has also been transformed in numbers.

In the text non-ASCII characters have been converted:

original char. -> result
-------------------------------------
     ä -> =E4
     ü -> =FC

I found also some main text of backed emails where the specific characters were o.k.. I cannot say which ones and why, even if the headers are always transformed.

I added this comment in the same thread, because the problem has to be seen in the context of the realized modifications above.

Revision history for this message
C Fraire (cfraire) wrote :

Hi, Winfried. That behavior is expected, since backup_gmail is storing the raw RFC2822+MIME text of the messages, which encodes non-ASCII elements in a variety of ways. This allows backup_gmail to do a fast, incremental archive of messages on Gmail.

You can be confident in this backup should anything ever happen to your Gmail data online, or should you desire to terminate Gmail at some point. But it is not meant to be full-text searchable. One option you have is to use backup_gmail to do an mbox export of your backup directory. You could then open an mbox in an email reader and search or read its contents.

The following exports the entire backup directory, all messages, one mbox per label:

    python backup_gmail.py <backup_dir> --mbox_export=<export_dir>

You can also filter the export, for example to --include only certain labels or by date (e.g., --start <d>):

    python backup_gmail.py <backup_dir> --mbox_export=<export_dir> --include=Label1^Label2 --start 1-Okt-2001

Revision history for this message
Saarloop (winfried100) wrote :

Hi C Fraire,

now the procedure is very clear and understandable. I thank you very much for your the mentioned solutions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.