duplicity-team team mailing list archive
-
duplicity-team team
-
Mailing list archive
-
Message #02921
[Merge] lp:~sjakthol/duplicity/onedrive-error-message into lp:duplicity
Sami Jaktholm has proposed merging lp:~sjakthol/duplicity/onedrive-error-message into lp:duplicity.
Commit message:
* Add proper error message for OneDrive backend when python-requests or
python-requests-oauthlib is not installed (bug 1453355).
Requested reviews:
duplicity-team (duplicity-team)
For more details, see:
https://code.launchpad.net/~sjakthol/duplicity/onedrive-error-message/+merge/258706
This makes the error message better if user tries to use OneDrive backend when python-requests or python-requests-oauthlib is not installed.
--
Your team duplicity-team is requested to review the proposed merge of lp:~sjakthol/duplicity/onedrive-error-message into lp:duplicity.
=== modified file 'duplicity/backends/onedrivebackend.py'
--- duplicity/backends/onedrivebackend.py 2015-03-18 15:34:33 +0000
+++ duplicity/backends/onedrivebackend.py 2015-05-09 06:44:34 +0000
@@ -25,12 +25,6 @@
import json
import os
import sys
-# On debian (and derivatives), get these dependencies using:
-# apt-get install python-requests python-requests-oauthlib
-# On fedora (and derivatives), get these dependencies using:
-# yum install python-requests python-requests-oauthlib
-import requests
-from requests_oauthlib import OAuth2Session
import duplicity.backend
from duplicity.errors import BackendException
@@ -65,6 +59,23 @@
def __init__(self, parsed_url):
duplicity.backend.Backend.__init__(self, parsed_url)
+
+ # Import requests and requests-oauthlib
+ try:
+ # On debian (and derivatives), get these dependencies using:
+ # apt-get install python-requests python-requests-oauthlib
+ # On fedora (and derivatives), get these dependencies using:
+ # yum install python-requests python-requests-oauthlib
+ global requests
+ global OAuth2Session
+ import requests
+ from requests_oauthlib import OAuth2Session
+ except ImportError:
+ raise BackendException((
+ 'OneDrive backend requires python-requests and '
+ 'python-requests-oauthlib to be installed. Please install '
+ 'them and try again.'))
+
self.names_to_ids = None
self.user_id = None
self.directory = parsed_url.path.lstrip('/')
References