Commit Graph

2753 Commits

Author SHA1 Message Date
Rodolfo García Peñas (kix)
3f7e9fe1bd Gmail.py Changed comments to docstring
This patch changes the comments in these functions to docstrings
and remove pylint warnings.
2020-11-01 08:57:43 +01:00
Rodolfo García Peñas (kix)
fc2055de8c Gmail.py else statement not needed
Always is else here.
2020-11-01 08:54:16 +01:00
Rodolfo García Peñas (kix)
0454e3e2f1 Gmail.py swap if block
I swapped this if - else block, with the "is not". Code now is clear.
2020-11-01 08:53:08 +01:00
Rodolfo García Peñas (kix)
4198fa8201 Gmail.py else statement not needed
We don't need speficify the else here. Always is else.
2020-11-01 08:51:03 +01:00
Rodolfo García Peñas (kix)
d50a28a68f repository add docstring to files
This patch includes the docstrings for all files, removing the pylint
warning
2020-11-01 08:43:16 +01:00
Rodolfo García Peñas (kix)
e5f0f10334 distro_utils.py renamed variable f
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)
2020-11-01 08:31:47 +01:00
Rodolfo García Peñas (kix)
b51fa3b9f6 distro_utils.py get dictionary value using get
This patch use get to get the value of os_name. Else, None is get.
2020-11-01 08:29:15 +01:00
Rodolfo García Peñas (kix)
4e31762ec6 distro_utils.py added docstring
Remove pylint warning about

C0114: Missing module docstring (missing-module-docstring)
2020-11-01 08:23:28 +01:00
Rodolfo García Peñas (kix)
9f34b14f72 const.py added docstring
Remove pylint warning about

C0114: Missing module docstring (missing-module-docstring)
2020-11-01 08:22:44 +01:00
Rodolfo García Peñas (kix)
3be65bf5dd pylint renamed variables
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
2020-11-01 08:21:24 +01:00
Rodolfo García Peñas (kix)
cbfcd38bca stacktrace.py added docstring
Removed warning:

C0114: Missing module docstring (missing-module-docstring)
2020-11-01 08:16:19 +01:00
Rodolfo García Peñas (kix)
9239c804e9 Base.py remove redundant parenthesis
Just remove these parenthesis
2020-10-31 16:55:58 +01:00
Rodolfo García Peñas (kix)
8504cdc6b8 Base.py long lines style
This patch changes long lines (>80 chars) to lines <80 chars.
The patch only changes the style.
2020-10-31 16:55:20 +01:00
Rodolfo García Peñas (kix)
23f67019cc Base.py long lines style
This patch changes long lines (>80 chars) to lines <80 chars.
The patch only changes the style.
2020-10-31 16:43:52 +01:00
Rodolfo García Peñas (kix)
332a6d7240 IMAP.py long lines style
This patch changes long lines (>80 chars) to lines <80 chars.
The patch only changes the style.
2020-10-31 16:14:53 +01:00
Rodolfo García Peñas (kix)
1ce229ca9d IMAP.py comparison with None should use is
Comparison with None should be "is" not "=="
2020-10-31 16:12:02 +01:00
Rodolfo García Peñas (kix)
2f2f4ef918 IMAP.py long lines style
This patch changes long lines (>80 chars) to lines <80 chars.
The patch only changes the style.
2020-10-31 16:09:34 +01:00
Rodolfo García Peñas (kix)
5033340c2f IMAP.py should use encoding to read the file
This patch includes the word "encoding" to select the right argument in remotepassfile.
2020-10-31 15:53:45 +01:00
Rodolfo García Peñas (kix)
cbbeebbf44 imapserver.py removed extra parenthesis
We can remove this parenthesis.
2020-10-31 15:39:28 +01:00
Rodolfo García Peñas (kix)
0e90bcbf38 IMAP.py too many arguments for string format
We need only two arguments, not three. We can remove the self argument.
2020-10-31 15:37:50 +01:00
Rodolfo García Peñas (kix)
352133dcc0 call to setDaemon uses Bool argument
The argument 1 should be True in these files.
2020-10-31 15:35:54 +01:00
Rodolfo García Peñas (kix)
78aeed20a9 imapserver call to OfflineImapError with right arguments
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.
2020-10-31 15:29:24 +01:00
Rodolfo García Peñas (kix)
26efc62ba7 imapserver import style
This patch removes the unused import socket line. (warning)

Split the line with multiple imports in different lines. (warning)
2020-10-31 15:24:40 +01:00
Rodolfo García Peñas (kix)
24a3692b68
Merge pull request #20 from thekix/master
Updated cram-md5 authentication
2020-10-31 00:12:42 +01:00
Rodolfo García Peñas (kix)
a60ca038ce Updated cram-md5 authentication
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>
2020-10-31 00:09:38 +01:00
Rodolfo García Peñas (kix)
df16bd595d
Merge pull request #17 from thekix/master
Use system sslcacertfile by default
2020-10-27 07:52:34 +01:00
Rodolfo García Peñas (kix)
a4863b2f04 Use system sslcacertfile by default
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
2020-10-26 12:10:49 +01:00
Rodolfo García Peñas (kix)
c850e745cc
Merge pull request #15 from thekix/master
imaplib expect bytes in the append
2020-10-25 20:38:03 +01:00
Rodolfo García Peñas (kix)
442c88d838 imaplib expect bytes in the append
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')
2020-10-25 20:36:07 +01:00
Rodolfo García Peñas (kix)
5e7b006540
Merge pull request #13 from thekix/master
Updated test code
2020-10-25 19:39:06 +01:00
Rodolfo García Peñas (kix)
27351d9e90 Test global calls AttributeError
This patch raises the AttributeError.
2020-10-25 19:34:52 +01:00
Rodolfo García Peñas (kix)
7df190cef1 setup.py code style 2020-10-25 19:23:52 +01:00
Rodolfo García Peñas (kix)
519fc8a8d6 Removed comment about python2 2020-10-25 19:21:58 +01:00
Rodolfo García Peñas (kix)
70bf1c74c4 Removed not used variables returned by run_OLI
These variables are not used in these functions, we can remove them.
2020-10-25 19:18:21 +01:00
Rodolfo García Peñas (kix)
c20db9ef7e Remove assserts in OLI test 6
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().
2020-10-25 19:17:19 +01:00
Rodolfo García Peñas (kix)
2b2994d68e Remove asssert in OLI test 3
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().
2020-10-25 19:17:19 +01:00
Rodolfo García Peñas (kix)
a3aaa19d79 Remove asssert in OLI test 2
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().
2020-10-25 19:09:30 +01:00
Rodolfo García Peñas (kix)
3231e731d8 Remove asssert in OLI test 1
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().
2020-10-25 19:09:30 +01:00
Rodolfo García Peñas (kix)
f19a23c532 Test delete_remote_testfolders updated to python3
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>
2020-10-25 19:09:30 +01:00
Rodolfo García Peñas (kix)
8dfef62db4 test_00_imaputil.py Runs fine
This patch changes the bytes to strings in test_00 and now
these tests run fine.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-10-25 18:13:03 +01:00
Rodolfo García Peñas (kix)
47f7b1ba3c get_os_sslcertfile_searchpath do not check iterable
Now, location is always an iterable, so we don't need check it.
2020-10-25 17:32:38 +01:00
Rodolfo García Peñas (kix)
a1f8576937 distro_utils do not compare types
This patch now use isinstance to compare types.
2020-10-25 17:27:40 +01:00
Rodolfo García Peñas (kix)
fe25a5c752 Distro default certificates must be iterables
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>
2020-10-25 17:26:20 +01:00
Rodolfo García Peñas (kix)
bde48fe2c7 Renamed l variable to location_name
This variable is renamed to avoid a warning about ambiguous name.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-10-25 16:42:09 +01:00
Rodolfo García Peñas (kix)
5777553a96 Renamed l variable to location_name
This variable is renamed to avoid a warning about ambiguous name.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-10-25 16:40:50 +01:00
Rodolfo García Peñas (kix)
714cbe2327 Renamed OS to os_name in get_os_sslcertificate_searchpath
This patch changes this variable name only.
2020-10-25 16:40:07 +01:00
Rodolfo García Peñas (kix)
07c1a5c9db Deprecated linux_distribution
The call from platform.linux_distribution was depdrecated in Python 3.7.

This patch solves this problem, using the recomended package distro.

Signed-off-by: Rodolfo García Peñas (kix) <kix@kix.es>
2020-10-25 16:38:16 +01:00
Rodolfo García Peñas (kix)
f66bfb0026 Renamed utils/distro.py
The file utils/distro.py is renamed to utils/distro_utils.py
because we need import the distro file to update some calls.

The file is used in IMAP.py, I need change the import.
2020-10-25 16:33:52 +01:00
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