Go to file
Thomas De Schampheleire 58d34df29f imapserver: fix exception handling in xoauth2handler
In case of an exception in XOAUTH2 code refresh (HTTP Error 400: Bad
Request), following exception occurs:

ERROR: While attempting to sync account 'xxx'
  __init__() missing 3 required positional arguments: 'msg', 'hdrs', and 'fp'

Traceback:
  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 648, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File ".../offlineimap3/offlineimap/imapserver.py", line 591, in acquireconnection
    self.__authn_helper(imapobj)
  File ".../offlineimap3/offlineimap/imapserver.py", line 448, in __authn_helper
    if func(imapobj):
  File ".../offlineimap3/offlineimap/imapserver.py", line 382, in __authn_xoauth2
    imapobj.authenticate('XOAUTH2', self.__xoauth2handler)
  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 682, in authenticate
    typ, dat = self._simple_command('AUTHENTICATE', mechanism.upper())
  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 1675, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 1395, in _command
    literal = literator(data, rqb)
  File ".../offlineimap3/venv/lib/python3.7/site-packages/imaplib2.py", line 2238, in process
    ret = self.mech(self.decode(data))
  File ".../offlineimap3/offlineimap/imapserver.py", line 257, in __xoauth2handler
    raise type(e)(msg, exc_info()[2])

The exception 'e' is of type HTTPError, which does not have the same kind of
constructor as normal Python exceptions.

Instead, print the constructed message and just raise the existing
exception.

With that change, the same condition triggers another problem further on:

ERROR: While attempting to sync account 'xxx'
  tuple index out of range

Traceback:
  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 648, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File ".../offlineimap3/offlineimap/imapserver.py", line 664, in acquireconnection
    elif isinstance(e, socket.error) and e.args[0] == errno.ECONNREFUSED:

because e.args is empty.
2021-01-04 10:26:01 +01:00
.github remove requests for reviews in github 2020-09-06 11:41:11 +02:00
bin Changed environment to python3 in offlineimap 2020-08-29 08:11:56 +02:00
contrib Included contrib nametrans_imap_to_utf8.py 2020-11-10 23:32:31 +01:00
docs docs/website-doc.sh: minor improvements in comments of versions.yml 2018-06-16 15:29:11 +02:00
offlineimap imapserver: fix exception handling in xoauth2handler 2021-01-04 10:26:01 +01:00
scripts scripts/get-repository.sh.rej: remove unused file 2017-01-31 01:01:53 +01:00
test Test global calls AttributeError 2020-10-25 19:34:52 +01:00
tests Autmomated testing using Travis and CodeCov.io! 2018-03-05 19:31:51 +01:00
.coveragerc Autmomated testing using Travis and CodeCov.io! 2018-03-05 19:31:51 +01:00
.gitignore gitignore: re-introduce *.css 2018-03-05 19:35:13 +01:00
.travis.yml travis: remove python3.6 2019-06-10 17:36:20 +02:00
Changelog.maint.md v6.7.0.3 2016-07-26 08:46:22 +02:00
Changelog.md v7.3.0 2019-08-19 19:17:53 +02:00
CODE_OF_CONDUCT.md code of conduct: try to clarify what item 3 might mean 2016-07-12 16:04:55 +02:00
CONTRIBUTING.rst explain how to submit issues in more files 2016-09-09 21:10:30 +02:00
COPYING COPYING: fix unexpected characters 2015-01-15 11:41:35 +01:00
MAINTAINERS.rst Updated MAINTAINERS.rst and README.md 2020-12-28 18:10:21 +01:00
Makefile Makefile: targz: don't set the abbrev in the archive directory name 2018-04-09 17:17:49 +02:00
MANIFEST.in MANIFEST: exclude rfcs 2016-02-27 05:25:09 +01:00
offlineimap.conf offlineimap.conf: minor fixes 2018-12-02 00:38:05 +01:00
offlineimap.conf.minimal Improve nametrans user documentation 2012-02-13 16:09:32 +01:00
offlineimap.py offlineimap.py using env python3 2020-08-29 08:30:38 +02:00
README.md Updated MAINTAINERS.rst and README.md 2020-12-28 18:10:21 +01:00
requirements.txt Deprecated linux_distribution 2020-10-25 16:38:16 +01:00
setup.cfg pypi requires a setup.cfg when README is Markdown 2016-02-27 05:34:46 +01:00
setup.py setup.py code style 2020-10-25 19:23:52 +01:00
snapcraft.yaml snapcraft uses python3 2020-08-29 09:15:00 +02:00
TODO.rst update TODO.rst 2015-11-23 02:24:33 +01:00

Upstream status (master branch): OfflineIMAP build status on Travis-CI.org OfflineIMAP code coverage on Codecov.io Gitter chat

Upstream status (next branch): OfflineIMAP build status on Travis-CI.org

Links:

OfflineIMAP

"Get the emails where you need them."

[Official offlineimap][offlineimap3].

Description

OfflineIMAP is software that downloads your email mailbox(es) as local Maildirs. OfflineIMAP will synchronize both sides via IMAP.

Why should I use OfflineIMAP?

IMAP's main downside is that you have to trust your email provider to not lose your email. While certainly unlikely, it's not impossible. With OfflineIMAP, you can download your Mailboxes and make you own backups of your Maildir.

This allows reading your email offline without the need for your mail reader (MUA) to support IMAP operations. Need an attachment from a message without internet connection? No problem, the message is still there.

Project status and future

OfflineIMAP, using Python 3, is based on OfflineIMAP for Python 2. Currently we are updating the source code. These changes should not affect the user (documentation, configuration files,... are the same) but some links or packages could refer to the Python 2 version. In that case, please open an issue.

License

GNU General Public License v2.

Downloads

You should first check if your distribution already packages OfflineIMAP for you. Downloads releases as tarball or zipball.

If you are running Linux Os, you can install offlineimap with:

  • openSUSE zypper in offlineimap
  • Arch Linux pacman -S offlineimap
  • fedora dnf install offlineimap

Feedbacks and contributions

The user discussions, development, announcements and all the exciting stuff take place on the mailing list. While not mandatory to send emails, you can subscribe here.

Bugs, issues and contributions can be requested to both the mailing list or the [official Github project][offlineimap3]. Provide the following information:

  • system/distribution (with version)
  • offlineimap version (offlineimap -V)
  • Python version
  • server name or domain
  • CLI options
  • Configuration file (offlineimaprc)
  • pythonfile (if any)
  • Logs, error
  • Steps to reproduce the error

The community

Requirements & dependencies

  • Python v3+
  • rfc6555 (required)
  • imaplib2 >= 3.5
  • gssapi (optional), for Kerberos authentication
  • portalocker (optional), if you need to run offlineimap in Cygwin for Windows

Documentation

All current and updated documentation is on the community's website.

Read documentation locally

You might want to read the documentation locally. Get the sources of the website. For the other documentation, run the appropriate make target:

$ ./scripts/get-repository.sh website
$ cd docs
$ make html  # Requires rst2html
$ make man   # Requires a2x (http://asciidoc.org)
$ make api   # Requires sphinx