From 3916205a9506421f8a1d38f73d1f81aa4e98a97f Mon Sep 17 00:00:00 2001 From: Jack Darlington Date: Thu, 16 Mar 2017 23:36:37 +0000 Subject: [PATCH] Gdrive optional --- cps/gdriveutils.py | 7 +++++-- cps/helper.py | 5 ++++- cps/web.py | 9 ++++++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cps/gdriveutils.py b/cps/gdriveutils.py index 9ec83059..5cf52307 100644 --- a/cps/gdriveutils.py +++ b/cps/gdriveutils.py @@ -1,5 +1,8 @@ -from pydrive.auth import GoogleAuth -from pydrive.drive import GoogleDrive +try: + from pydrive.auth import GoogleAuth + from pydrive.drive import GoogleDrive +except ImportError: + pass import os, time from ub import config diff --git a/cps/helper.py b/cps/helper.py index 424e1f2b..1a89c86c 100755 --- a/cps/helper.py +++ b/cps/helper.py @@ -35,7 +35,10 @@ import shutil import requests import zipfile from tornado.ioloop import IOLoop -import gdriveutils as gd +try: + import gdriveutils as gd +except ImportError: + pass import web try: diff --git a/cps/web.py b/cps/web.py index 59655755..4188afdd 100755 --- a/cps/web.py +++ b/cps/web.py @@ -1,6 +1,11 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from pydrive.auth import GoogleAuth +try: + from pydrive.auth import GoogleAuth + from googleapiclient.errors import HttpError + gdrive_support= True +except ImportError: + gdrive_support=False import mimetypes import logging @@ -56,8 +61,6 @@ import io import hashlib import threading -from googleapiclient.errors import HttpError - from tornado import version as tornadoVersion try: