Commit Graph

1738 Commits

Author SHA1 Message Date
Thomas De Schampheleire
820e5c855f IMAP: Python 3 bytes fix on first download of account
ERROR: ERROR in syncfolder for gmail folder INBOX: Traceback (most recent call last):
  File ".../offlineimap3/offlineimap/accounts.py", line 634, in syncfolder
    cachemessagelists_upto_date(maxage)
  File ".../offlineimap3/offlineimap/accounts.py", line 526, in cachemessagelists_upto_date
    min_date=time.gmtime(time.mktime(date) + 24 * 60 * 60))
  File ".../offlineimap3/offlineimap/folder/IMAP.py", line 277, in cachemessagelist
    imapobj, min_date=min_date, min_uid=min_uid)
  File ".../offlineimap3/offlineimap/folder/IMAP.py", line 259, in _msgs_to_fetch
    search_result = search(search_cond)
  File ".../offlineimap3/offlineimap/folder/IMAP.py", line 222, in search
    if ' ' in res_data[0] or res_data[0] == '':
TypeError: a bytes-like object is required, not 'str'
2020-10-21 14:28:23 +02:00
Rodolfo García Peñas (kix)
49c85d732d Using isinstance instead type
This patch uses isinstance, like Thomas pointed in their last commit.
2020-10-12 12:52:04 +02:00
Rodolfo García Peñas (kix)
d8149c1ec1
Merge pull request #7 from patrickdepinguin/py3fix
More python 3 related fixes
2020-10-12 12:44:19 +02:00
Rodolfo García Peñas (kix)
ba6857bc87 Remove email.Parse
The Parse funcion was deprecated in python 2.4. We can use this new
code.
2020-10-12 12:40:54 +02:00
Rodolfo García Peñas (kix)
62df6e70c3 Rigth comparison with err EEXIST
This is the right code. The OSError doesn't have the EEXIST variable.
2020-10-12 12:35:56 +02:00
Thomas De Schampheleire
c00af91990 accounts: decode output of hooks
When a hook is configured, the output is a bytes object.
This is then printed on the console/logfile as:

    2020-10-12 08:36:17 INFO: Hook stdout: b'Processed 3 total files in almost no time.\nAdded 3 new messages to the database.\n'
    Hook stderr:b''

Decode the output so that it is printed nicely, as:

    2020-10-12 08:36:17 INFO: Hook stdout: Processed 3 total files in almost no time.
    Added 3 new messages to the database.

    Hook stderr:

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
2020-10-12 09:01:59 +02:00
Thomas De Schampheleire
423785725b IMAP.py: server responses are in bytes, not string
Following error is seen when parsing server responses for sent mail:

2020-10-12 08:19:11 WARNING: Can't parse FETCH response, we awaited string: b' UID 26855)'
2020-10-12 08:19:11 WARNING: savemessage: Searching mails for new Message-ID failed. Could not determine new UID on Sent.

The comparison with 'type("")' means comparing with 'string' type in Python
3, but the left-hand side is a bytes object.

In case a tuple was received (first case in the code), the input is already
decoded from bytes to strings, but in case a single input was received it
was not.

Note that the comparison with 'type("")' is a bit odd, a more logical way
seems to be:
    if isinstance(item, bytes)

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
2020-10-12 09:01:51 +02:00
Rodolfo García Peñas (kix)
3d5f926552 Changed the doxygen in change_message_uid
This patch changes the doxygen and adds the ruid argument.
2020-10-11 23:57:17 +02:00
Rodolfo García Peñas (kix)
01c621d86c Allow folder names with atom specials
This patch allows using folders with atom-specials like
"(", ")", spaces,...

We need quotes the folder name if it includes this special
characters.

Closes #4
2020-10-11 23:01:08 +02:00
Rodolfo García Peñas (kix)
011cfbc670 Do not use built-in list variable
This patch changes the ilst built-in variable to l_list.
2020-10-10 18:59:04 +02:00
Rodolfo García Peñas (kix)
0c04611ca4 Changed doxygen parameter
The parameter regtype does not exists, it is reqtype.
2020-10-10 17:48:30 +02:00
Rodolfo García Peñas (kix)
bb05904cf1 Renamed variable already used
The variable l was used in tn the code, so we should change it in
this code block.
2020-10-10 17:24:18 +02:00
Rodolfo García Peñas (kix)
659b38bcf7 Base.py Comment unused code in savemessagelabels
This code is not used, we can comment it.
2020-10-10 17:23:05 +02:00
Rodolfo García Peñas (kix)
7ff65be690 Removed mutable arguments
This patch remves the set() mutable argument as default value,
sets the default value to None and check if the argument is none
in the code to call set().
2020-10-10 15:00:34 +02:00
Rodolfo García Peñas (kix)
fb909671c8 Removed doxygen param
This param does not exists in the monitor function.
2020-10-10 14:50:47 +02:00
Thomas De Schampheleire
78807b55b4 imapserver.py: fix __xoauth2handler in Python 3
Error when using the XOAUTH2 token refresh logic:

  ("POST data should be bytes, an iterable of bytes, or a file object. It cannot be of type str. (configuration is: {....}", <traceback object at 0x7fc6e69f2b40>)
     ['  File ".../offlineimap3/offlineimap/accounts.py", line 298, in syncrunner
        self.__sync()
    ', '  File ".../offlineimap3/offlineimap/accounts.py", line 374, in __sync
        remoterepos.getfolders()
    ', '  File ".../offlineimap3/offlineimap/repository/IMAP.py", line 446, in getfolders
        imapobj = self.imapserver.acquireconnection()
    ', '  File ".../offlineimap3/offlineimap/imapserver.py", line 579, in acquireconnection
        self.__authn_helper(imapobj)
    ', '  File ".../offlineimap3/offlineimap/imapserver.py", line 443, in __authn_helper
        if func(imapobj):
    ', '  File ".../offlineimap3/offlineimap/imapserver.py", line 377, in __authn_xoauth2
        imapobj.authenticate(\'XOAUTH2\', self.__xoauth2handler)
    ', '  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 681, in authenticate
        typ, dat = self._simple_command(\'AUTHENTICATE\', mechanism.upper())
    ', '  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 1674, in _simple_command
        return self._command_complete(self._command(name, *args), kw)
    ', '  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 1394, in _command
        literal = literator(data, rqb)
    ', '  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 2237, in process
        ret = self.mech(self.decode(data))
    ', '  File ".../offlineimap3/offlineimap/imapserver.py", line 253, in __xoauth2handler
        raise type(e)(msg, exc_info()[2])
    ']

Fix by encoding the data passed to urllib.

Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
2020-09-29 10:04:07 +02:00
Rodolfo García Peñas (kix)
7fff7fc458 repository/__init__.py remove try import python2
This patch removes the dup code between try and catch

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:10 +02:00
Rodolfo García Peñas (kix)
9123cb83fc Remove md5 import
The library md5 is only for python2, hashlib is used in python3

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:09 +02:00
Rodolfo García Peñas (kix)
bab7dd00c9 offlineimap/accounts added Exception with lock file
This patch includes an Exception to catch when two instances of
offlineimap are running.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:08 +02:00
Rodolfo García Peñas (kix)
35b588f57e six: changed offlineimap/repository/__init__.py
This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:05 +02:00
Rodolfo García Peñas (kix)
6321a66287 six: changed offlineimap/repository/IMAP.py
This patch removes the library six, compatible with python2.

I need change this re-raise call.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:04 +02:00
Rodolfo García Peñas (kix)
4e1558adc3 six: changed offlineimap/imapserver.py
This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:03 +02:00
Rodolfo García Peñas (kix)
edf22e0e96 six: changed offlineimap/imaplibutil.py
This patch removes the library six, compatible with python2.

I need change this re-raise call.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:02 +02:00
Rodolfo García Peñas (kix)
cefac73af4 six: changed offlineimap/folder/IMAP.py
This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:01 +02:00
Rodolfo García Peñas (kix)
ba11b2d684 six: changed offlineimap/folder/Maildir.py
This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:00 +02:00
Rodolfo García Peñas (kix)
4b32d62fe9 six: changed offlineimap/folder/GmailMaildir.py
This patch removes the library six, compatible with python2.

I need change this re-raise call.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:59 +02:00
Rodolfo García Peñas (kix)
bafcef77fd six: changed offlineimap/folder/Gmail.py
This patch removes the library six, compatible with python2.

I need change this re-raise call.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:58 +02:00
Rodolfo García Peñas (kix)
75c718c75b six: changed offlineimap/folder/UIDMaps.py
This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:57 +02:00
Rodolfo García Peñas (kix)
dd3e7616cf six: changed offlineimap/folder/LocalStatusSQLite.py
This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:56 +02:00
Rodolfo García Peñas (kix)
a922ab3103 six: changed offlineimap/folder/LocalStatus.py
This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:55 +02:00
Rodolfo García Peñas (kix)
493aefc09d six: changed offlineimap/CustomConfig.py
This patch removes the library six, compatible with python2.

I need change this re-raise call.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:54 +02:00
Rodolfo García Peñas (kix)
b8137a8028 six: changed offlineimap/accounts.py
This patch removes the library six, compatible with python2.

I need change these re-raise calls.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:53 +02:00
Rodolfo García Peñas (kix)
df4b9174d7 IMAP.py __savemessage_fetchheaders decode bytes
This patch changes the function __savemessage_fetchheaders to decode the
bytes retunred by imaplib2.

We need a list of headers, with string values, but imapli2 is providing
a list with bytes. This change convert the values to str.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:52 +02:00
Rodolfo García Peñas (kix)
b24687fcd6 Gmail.py Get the server response right
Now, the server response is in a list of strings. We need the second
string, so we need read the [1].

Previously, was a list of tuples, so, we used [0][1].

This patch is like the patch IMAP.py Get the server response right, but
now for Gmail.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:51 +02:00
Rodolfo García Peñas (kix)
6f622c7b27 repository/IMAP.py getselectors updated
In the patch "IMAP list folders" we updated the function getselectors
to return '""'. We use this variable in the folders, but also here.

Because the variable is never '', we need update it with this change, to
test that the variable has value, but is not empty.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:49 +02:00
Rodolfo García Peñas (kix)
8e63f58b22 folder/IMAP.py matching uids is a list
matchinguids variable is a list of UIDs, separated by spaces. You can
check it some lines later, using the split command.

We need decode the bytes value returned by imaplib2 and convert it to
sting.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:35:48 +02:00
Rodolfo García Peñas (kix)
41c2ced1d5 IMAP.py _msgs_to_fetch decode bytes
imaplib2 returns the type as string, like "OK" but
returns imapdata as list of bytes, like [b'0'] so we need decode it
to use the existing code
2020-09-01 19:07:52 +02:00
Rodolfo García Peñas (kix)
caaa953616 IMAP.py list folders
This patch changes the refernce to "", because now the empty string
is not saved as '""', is just '', so the fecth command fails.

Then, I changed the fech call to "" "*", using refernce "" and pattern
"*".
2020-09-01 18:21:27 +02:00
Rodolfo García Peñas (kix)
7947aea7a9 imapserver call LIST using empty quotes
The LIST command needs empty quotes, like

LIST ""

This is the right argument.
2020-09-01 18:21:27 +02:00
Rodolfo García Peñas (kix)
1ff54e7a7c IMAP.py Get the server response right
Now, the server response is in a list of strings. We need the second
string, so we need read the [1].

Previously, was a list of tuples, so, we used [0][1].
2020-09-01 18:21:27 +02:00
Rodolfo García Peñas (kix)
ea8c0c6f3e __generate_randomheader uses now string
This patch converts the string to bytes to use crc32.

We can remore the fffffff because in python3 is always positive value.
In other patch.
2020-09-01 17:40:12 +02:00
Rodolfo García Peñas (kix)
7980f7ff1a IMAP.py calls Internaldate2epoch with bytes argument
The function Internaldate2epoch needs a bytes argument,
not an string, we need encode it:

imaplibutil.Internaldate2epoch(messagestr.encode('utf-8'))
2020-09-01 17:40:12 +02:00
Rodolfo García Peñas (kix)
b6cec81090 imalplibutil calls strptime with string
datetime.datetime.strptime wants a string object,
but we have a bytes object. We need decode it.
2020-08-31 18:12:29 +02:00
Rodolfo García Peñas (kix)
d011702b5b removed virtual_imaplib2
Now we use the system imaplib2. I am using Debian.
2020-08-31 16:24:26 +02:00
Rodolfo García Peñas (kix)
4d293c8eea threadutil.py removed extra parenthesys
These characters could be removed.
2020-08-30 18:54:52 +02:00
Rodolfo García Peñas (kix)
16f46c81cd threadutil.py changed not var in
This patch changes:

if not var1 in var2

with

if var1 not in var2
2020-08-30 18:54:01 +02:00
Rodolfo García Peñas (kix)
239b921056 mbnames.py removed extra parenthesys
These characters could be removed.
2020-08-30 18:53:02 +02:00
Rodolfo García Peñas (kix)
36ab6066e8 localeval.py removed extra parenthesys
These characters could be removed.
2020-08-30 18:52:56 +02:00
Rodolfo García Peñas (kix)
64cb6c45ec init.py removed unused variable
This variable is not used later.
2020-08-30 18:50:58 +02:00
Rodolfo García Peñas (kix)
fff1687e43 init.py warn is deprecated, using warning
loggin.warn is changed to loggin.warning
2020-08-30 18:49:50 +02:00