First, in Python 3 we don't need call the super().__init__ explicitly, because Python does it. So, we can remove the line:
super().__init__(reposname, account)
If we leafe the method __init__ empty, the parent __init__ method is not called, we need remove the __init__ and then Python uses the parent __init__ method.
The variable f is renamed to l_file to avoid pylint warning:
utils/distro_utils.py:95:8: C0103: Variable name "f" doesn't conform to snake_case naming style (invalid-name)
This patch renames some variables to avoid pylint warning about
Variable name "f" doesn't conform to snake_case naming style (invalid-name)
f is now file
th is now the_en
n is now count
Call to OfflineImapError has the arguments:
- message
- severity
- error code
The None argument ir wrong here, we can remove it and then we have three arguments not four.
This patch updates the cram-md5 auth. We include two steps:
- Convert the password variable from string to bytes. This change is
because in Python2 strings and bytes are the same, but not in Python3
- Updates the call to hmac.new, now the digestmod argument is mandatory.
I used hashlib.md5, because we need md5 hash.
Closes#19
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
This patch includes a new functionality to get the sslcacertfile.
With this patch is possible to remove the sslcacertfile variable form the
.offlineimaprc and use the system's default. This could be easy for new users.
With this patch, the user can use ssl without the sslcacertfile option
in .offlineimaprc, use sslcacertfile = <empty> (no include anything
after the equal sign, os specify the sslcacertfile as previosly.
Currently, these are the options:
User specifies sslacertfile -> OK
User specifies sslacertfile=OS-DEFAULT
If the system's default is provided -> OK
If the system's default is not provided -> Fail
User do not specifies sslacertfile -> Fail
User specifies empty sslacertfile -> Fail
With the new option (this patch).
User specifies sslacertfile -> OK
User specifies sslacertfile=OS-DEFAULT or
User do not specifies sslacertfile or
User specifies empty sslacertfile
If the system's default is provided -> OK
If the system's default is not provided -> Fail
Closes#14
imaplib2 is doing this code for strings:
if isinstance(message, str):
message = bytes(message, 'ASCII')
But our message is already encoded using 'utf-8'.
Then, we can set the message as bytes, encoded using 'utf-8'
in offlineimap and imaplib2 won't change our message.
This patch solves this problem:
WARNING:OfflineImap:
Traceback:
File "/home/kix/src/offlineimap3/offlineimap/folder/Base.py", line 1127, in syncmessagesto
action(dstfolder, statusfolder)
File "/home/kix/src/offlineimap3/offlineimap/folder/Base.py", line 955, in __syncmessagesto_copy
self.copymessageto(uid, dstfolder, statusfolder, register=0)
File "/home/kix/src/offlineimap3/offlineimap/folder/Base.py", line 855, in copymessageto
new_uid = dstfolder.savemessage(uid, message, flags, rtime)
File "/home/kix/src/offlineimap3/offlineimap/folder/IMAP.py", line 668, in savemessage
(typ, dat) = imapobj.append(self.getfullIMAPname(),
File "/usr/lib/python3/dist-packages/imaplib2.py", line 660, in append
message = bytes(message, 'ASCII')
We cannot use these asserts, becasue the returned value of res is:
ERROR: getfolder() asked for a nonexisting folder 'INBOX.OLItest'.
ERROR: Exceptions occurred during the run!
ERROR: getfolder() asked for a nonexisting folder 'INBOX.OLItest'.
So, if we have an assert, to compare if the string is empty,
the test stops here. We can check if we have or not folder in the
next check (count_maildir_mails().
We cannot use this assert, becasue the returned value of res is:
ERROR: getfolder() asked for a nonexisting folder 'INBOX.OLItest'.
ERROR: Exceptions occurred during the run!
ERROR: getfolder() asked for a nonexisting folder 'INBOX.OLItest'.
So, if we have an assert, to compare if the string is empty,
the test stops here. We can check if we have or not folder in the
next check (count_maildir_mails().
We cannot use this assert, becasue the returned value of res is:
ERROR: getfolder() asked for a nonexisting folder 'INBOX.OLItest'.
ERROR: Exceptions occurred during the run!
ERROR: getfolder() asked for a nonexisting folder 'INBOX.OLItest'.
So, if we have an assert, to compare if the string is empty,
the test stops here. We can check if we have or not folder in the
next check (count_maildir_mails().
We cannot use this assert, becasue the returned value of res is:
ERROR: Account test: no folder to sync (f[388 chars]\n\n' != ''
- ERROR: Account test: no folder to sync (folderfilter issue?)
- ERROR: Exceptions occurred during the run!
- ERROR: Account test: no folder to sync (folderfilter issue?)
So, if we have an assert to test if the string is empty,
the test stops here. We can check if we have or not folder
in the next check (count_maildir_mails().
This patch changes the test to use always strings and not bytes or
bytearrays.
Now the test runs fine.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
This patch changes the __DEF_OS_LOCATIONS to an iterable value.
The reason is because a list is an iterable, but an string is an
iterable too, and this is a mistake.
The function get_os_sslcertfile() has a loop to iterate the return of
get_os_sslcertfile_searchpath(), that returns the value in the
__DEF_OS_LOCATIONS dictionary. When the value is an iterable, the "f"
variable is set to the iterable value and works fine.
If the value of "f" is an string, the for-loop iterates over every
character, so the test for os.path.exists is always false (is comparing
the path with a character, not with the full path), so this function
fails and return None.
To check this change, edit your .offlineimaprc file and change the
sslcacertfile to OS-DEFAULT:
sslcacertfile = OS-DEFAULT
And run offlineimap. If you are not using 'darwin0 (the only iterable)
it will fails. Now, apply this patch, and run offlineimap again. Problem
is solved.
Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>