Merge pull request #406 from pimutils/fix-google2

More bugfixes for Google
This commit is contained in:
Markus Unterwaditzer 2016-04-06 18:47:20 +02:00
commit 69b88dd0c0
2 changed files with 12 additions and 9 deletions

View file

@ -387,7 +387,7 @@ def storage_instance_from_config(config, create=True):
def handle_storage_init_error(cls, config):
e = sys.exc_info()[1]
if isinstance(e, (click.Abort, exceptions.UserError, KeyboardInterrupt)):
if not isinstance(e, TypeError) or '__init__' not in repr(e):
raise
all, required = get_storage_init_args(cls)
@ -398,19 +398,17 @@ def handle_storage_init_error(cls, config):
problems = []
if missing:
cli_logger.critical(
problems.append(
u'{} storage requires the parameters: {}'
.format(cls.storage_name, u', '.join(missing)))
if invalid:
cli_logger.critical(
problems.append(
u'{} storage doesn\'t take the parameters: {}'
.format(cls.storage_name, u', '.join(invalid)))
if not problems:
if not isinstance(e, exceptions.UserError):
cli_logger.exception('')
problems.append(str(e))
if not problems: # XXX: Py2: Proper reraise
raise e
raise exceptions.UserError(
u'Failed to initialize {}'.format(config['instance_name']),

View file

@ -26,12 +26,17 @@ except ImportError:
class GoogleSession(dav.DavSession):
def __init__(self, token_file, client_id=None, client_secret=None):
def __init__(self, token_file, url=None, client_id=None,
client_secret=None):
# Not a default in function signature, otherwise these show up in user
# documentation
client_id = client_id or CLIENT_ID
client_secret = client_secret or CLIENT_SECRET
# Required for discovering collections
if url is not None:
self.url = url
self.useragent = client_id
self._settings = {}
@ -157,4 +162,4 @@ class GoogleContactsStorage(dav.CarddavStorage):
# This is ugly: We define/override the entire signature computed for the
# docs here because the current way we autogenerate those docs are too
# simple for our advanced argspec juggling in `vdirsyncer.storage.dav`.
__init__._traverse_superclass = False
__init__._traverse_superclass = base.Storage