J. Tull heavytull at
Sun Aug 26 15:23:51 BST 2018

i'm trying to use the "remotepasseval" option to assign passwords in
the offlineimap rc file. I wrote a python function that uses gpg2 to
echo the password. That function is the following:

    import re
    import subprocess as sb
    def bashcmd(command):
        p = re.compile(r' ')

and in the rc file i put:

    remotepasseval = bashcmd('/usr/bin/gpg2 -dq --no-tty my_pass.gpg')

but offlineimap crashes, below is the output, and note that it prints
in plain text the decoded content of my_pass.gpg ===================================
$ offlineimap -c .offlineimaprc/offlineimap.conf -a acc_outlook                    ||
OfflineIMAP 7.2.0                                                                  ||
  Licensed under the GNU GPL v2 or any later version (with an OpenSSL exception)   ||
imaplib2 v2.57 (bundled), Python v2.7.15, OpenSSL 1.0.2p  14 Aug 2018              ||
Account sync acc_outlook:                                                          ||
 *** Processing account acc_outlook                                                ||
 Establishing connection to (acc_outlookremote)          ||
>>> decoded content of my_pass.gpg is printed here <<<    <=========================
 ERROR: While attempting to sync account 'acc_outlook'
  'NoneType' object has no attribute 'encode'
 *** Finished account 'acc_outlook' in 0:01
ERROR: Exceptions occurred during the run!
ERROR: While attempting to sync account 'acc_outlook'
  'NoneType' object has no attribute 'encode'

  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 283, in syncrunner
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 359, in __sync
  File "/usr/lib64/python2.7/site-packages/offlineimap/repository/", line 452, in getfolders
    imapobj = self.imapserver.acquireconnection()
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 550, in acquireconnection
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 414, in __authn_helper
    if func(imapobj):
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 340, in __authn_plain
    imapobj.authenticate('PLAIN', self.__plainhandler)
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 734, in authenticate
    typ, dat = self._simple_command('AUTHENTICATE', mechanism.upper())
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 1740, in _simple_command
    return self._command_complete(self._command(name, *args), kw)
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 1466, in _command
    literal = literator(data, rqb)
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 2331, in process
    ret = self.mech(self.decode(data))
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 203, in __plainhandler
    passwd = self.__getpassword()
  File "/usr/lib64/python2.7/site-packages/offlineimap/", line 177, in __getpassword
    self.password = self.repos.getpassword() or \
  File "/usr/lib64/python2.7/site-packages/offlineimap/repository/", line 392, in getpassword
    return self.localeval.eval(passwd).encode('UTF-8')

More information about the OfflineIMAP-project mailing list