Commit Graph

2755 Commits

Author SHA1 Message Date
Rodolfo García Peñas (kix)
faff27f0c9 Renamed variable DISTRO to distro_name
Variable DISTRO should be lowercase. I renamed it to distro_name.
2020-10-25 15:47:50 +01:00
Rodolfo García Peñas (kix)
997f5b27c5 Renamed variable OS to os_name
Variable OS should be in lowercase.
2020-10-25 15:47:22 +01:00
Rodolfo García Peñas (kix)
d03767bbe2 Removed unused import
This import (os) is not used.
2020-10-25 15:47:02 +01:00
Rodolfo García Peñas (kix)
c4baa15b3b Updated test README file
This patch updates the README Test file for python3.
2020-10-25 15:46:54 +01:00
Rodolfo García Peñas (kix)
bfe16e32a2 TestRunner.py change virtual_imaplib with imaplib2
This patch uses the system imaplib2 library.

Closes #12
2020-10-25 15:46:08 +01:00
Rodolfo García Peñas (kix)
b741da2853
Merge pull request #11 from patrickdepinguin/py3fix
Some more Python 3 related fixes.
2020-10-25 15:43:47 +01:00
Thomas De Schampheleire
33e0efa163 IMAP: replace non-UTF-8 characters rather than aborting
Emails received may not be UTF-8. Following error was observed on a specific
mail:

Traceback (most recent call last):
  File "/home/tdescham/repo/offlineimap3/offlineimap/threadutil.py", line 146, in run
    Thread.run(self)
  File "/usr/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/tdescham/repo/offlineimap3/offlineimap/folder/Base.py", line 850, in copymessageto
    message = self.getmessage(uid)
  File "/home/tdescham/repo/offlineimap3/offlineimap/folder/IMAP.py", line 327, in getmessage
    data = self._fetch_from_imap(str(uid), self.retrycount)
  File "/home/tdescham/repo/offlineimap3/offlineimap/folder/IMAP.py", line 844, in _fetch_from_imap
    ndata1 = data[0][1].decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 10177: invalid start byte

This completely aborted offlineimap3, blocking further mail reception.

Instead, use the 'replace' error strategy in Python:

    Replace with a suitable replacement character; Python will use the
    official U+FFFD REPLACEMENT CHARACTER for the built-in Unicode codecs on
    decoding and ‘?’ on encoding.
    https://docs.python.org/2/library/codecs.html#codec-base-classes
2020-10-21 16:29:13 +02:00
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)
4c46cffcc8
Merge pull request #9 from thekix/master
Using isinstance instead type
2020-10-12 12:56:58 +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)
9a994ced7a
Merge pull request #8 from thekix/master
Remove email.Parse and other minor changes
2020-10-12 12:43:54 +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)
941d69c7b4
Merge pull request #6 from thekix/master
Solves issue #4 and some cleanup
2020-10-11 23:05:59 +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
Rodolfo García Peñas (kix)
e62c8b39bf
Merge pull request #5 from patrickdepinguin/py3fix
imapserver.py: fix __xoauth2handler in Python 3
2020-09-30 23:12:33 +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)
8dca9168ec
Merge pull request #3 from nicolas33/ns/code-review
remove requests for reviews in github
2020-09-06 14:15:33 +02:00
Rodolfo García Peñas (kix)
f12e689326
Merge pull request #2 from svetlemodry/archlinux-naming-convetion-patch-1
Update README.md with proper Arch Linux naming convention
2020-09-06 14:15:06 +02:00
Nicolas Sebrecht
514744a0eb remove requests for reviews in github
Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
2020-09-06 11:41:11 +02:00
Jaroslav Lichtblau
e2204ba06b
Update README.md
https://wiki.archlinux.org/index.php/Arch_terminology#Arch_Linux
2020-09-06 09:45:43 +02:00
Rodolfo García Peñas (kix)
7625012179
Merge pull request #1 from thekix/master
Remove six, remove files rfc6555.py and selectors2.py and allow download mail from IMAP and Gmail
2020-09-03 21:48:29 +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)
0b9b09f265 Removed six
This patch finally removes the six library.

I removed the requirement, and also removes it in the README.md.

I changed the imlib2 library too, version 3.5

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-09-03 21:36:06 +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