Duplicity webdav: AttributeError: 'module' object has no attribute 'warn'

20. August 2017
bug backup linux

I use happily duply as my backup solution. This is a frontend for duplicity, an encrypted, bandwidth-efficient backup system using the rsync algorithm. To store the backups I use a different server of mine with plenty of storage, but which runs Windows Server unfortunately. So the only easy way of transferring the files seemed to be via webdav, which is natively supported by duplicity.

After setting up the webdav server and creating a new backup profile with duply the backup process was aborted with the error message AttributeError: 'module' object has no attribute 'warn'. Due to my lack of python knowledge the error was not very helpful to me, neither were the internet search results. Finally I had the idea to have a look at the source code and promptly found the culprit. Have a look at backends/webdavbackend.py:

if token.split(',')[0].lower() == 'negotiate':
    try:
        return self.get_kerberos_authorization()
    except ImportError:
        log.warn(_("python-kerberos needed to use kerberos \
                  authorization, falling back to basic auth."))
        return self.get_basic_authorization()
    except Exception as e:
        log.warn(_("Kerberos authorization failed: %s.\
                  Falling back to basic auth.") % e)
        return self.get_basic_authorization()

There we can see two calls to log.warn, which cause the error. The log module does not have a warn method, but it does have a Warn method. So just change lines 260 and 264 to contain log.Warn(), with an uppercase W, and everything works fine.

I reported the bug to the maintainers, so it will be fixed in the next version hopefully.

EDIT: The maintainers commited a fix, so this bug should be fixed from now.