From 2fb7a8d99f8c0240cfb9b3683487da3f1ebcfb5f Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Wed, 6 Apr 2016 15:14:55 +0200 Subject: [PATCH 1/2] More bugfixes for Google --- vdirsyncer/storage/google.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vdirsyncer/storage/google.py b/vdirsyncer/storage/google.py index e57ad15..263e100 100644 --- a/vdirsyncer/storage/google.py +++ b/vdirsyncer/storage/google.py @@ -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 From b3c1b00f1bed551f14f427142c30796246575f15 Mon Sep 17 00:00:00 2001 From: Markus Unterwaditzer Date: Wed, 6 Apr 2016 15:19:34 +0200 Subject: [PATCH 2/2] Refactor handle_storage_init_error --- vdirsyncer/cli/utils.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vdirsyncer/cli/utils.py b/vdirsyncer/cli/utils.py index d896e80..d4f2c73 100644 --- a/vdirsyncer/cli/utils.py +++ b/vdirsyncer/cli/utils.py @@ -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']),