mirror of
https://github.com/samsonjs/vdirsyncer.git
synced 2026-04-27 14:57:41 +00:00
Merge pull request #466 from pimutils/collections-null-google
Improve error for unsupported collections = null
This commit is contained in:
commit
a8c79ed1fc
4 changed files with 16 additions and 1 deletions
|
|
@ -137,6 +137,11 @@ def handle_cli_error(status_name=None):
|
||||||
'the issue tracker at {}'
|
'the issue tracker at {}'
|
||||||
.format(e, BUGTRACKER_HOME)
|
.format(e, BUGTRACKER_HOME)
|
||||||
)
|
)
|
||||||
|
except exceptions.CollectionRequired as e:
|
||||||
|
cli_logger.error(
|
||||||
|
'One or more storages don\'t support `collections = null`. '
|
||||||
|
'You probably want to set `collections = ["from a", "from b"]`.'
|
||||||
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
tb = sys.exc_info()[2]
|
tb = sys.exc_info()[2]
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
||||||
|
|
@ -75,3 +75,7 @@ class InvalidResponse(Error, ValueError):
|
||||||
|
|
||||||
class UnsupportedMetadataError(Error, NotImplementedError):
|
class UnsupportedMetadataError(Error, NotImplementedError):
|
||||||
'''The storage doesn't support this type of metadata.'''
|
'''The storage doesn't support this type of metadata.'''
|
||||||
|
|
||||||
|
|
||||||
|
class CollectionRequired(Error):
|
||||||
|
'''`collection = null` is not allowed.'''
|
||||||
|
|
|
||||||
|
|
@ -124,6 +124,9 @@ class GoogleCalendarStorage(dav.CaldavStorage):
|
||||||
|
|
||||||
def __init__(self, token_file, client_id, client_secret, start_date=None,
|
def __init__(self, token_file, client_id, client_secret, start_date=None,
|
||||||
end_date=None, item_types=(), **kwargs):
|
end_date=None, item_types=(), **kwargs):
|
||||||
|
if not kwargs.get('collection'):
|
||||||
|
raise exceptions.CollectionRequired()
|
||||||
|
|
||||||
super(GoogleCalendarStorage, self).__init__(
|
super(GoogleCalendarStorage, self).__init__(
|
||||||
token_file=token_file, client_id=client_id,
|
token_file=token_file, client_id=client_id,
|
||||||
client_secret=client_secret, start_date=start_date,
|
client_secret=client_secret, start_date=start_date,
|
||||||
|
|
@ -155,6 +158,9 @@ class GoogleContactsStorage(dav.CarddavStorage):
|
||||||
storage_name = 'google_contacts'
|
storage_name = 'google_contacts'
|
||||||
|
|
||||||
def __init__(self, token_file, client_id, client_secret, **kwargs):
|
def __init__(self, token_file, client_id, client_secret, **kwargs):
|
||||||
|
if not kwargs.get('collection'):
|
||||||
|
raise exceptions.CollectionRequired()
|
||||||
|
|
||||||
super(GoogleContactsStorage, self).__init__(
|
super(GoogleContactsStorage, self).__init__(
|
||||||
token_file=token_file, client_id=client_id,
|
token_file=token_file, client_id=client_id,
|
||||||
client_secret=client_secret,
|
client_secret=client_secret,
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,6 @@ class RemoteStorageCalendars(RemoteStorage):
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if not kwargs.get('collection'):
|
if not kwargs.get('collection'):
|
||||||
raise ValueError('The collections parameter is required.')
|
raise exceptions.CollectionRequired()
|
||||||
|
|
||||||
super(RemoteStorageCalendars, self).__init__(**kwargs)
|
super(RemoteStorageCalendars, self).__init__(**kwargs)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue