How to use the vdirsyncer.exceptions.Error function in vdirsyncer

To help you get started, we’ve selected a few vdirsyncer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pimutils / vdirsyncer / tests / storage / dav / __init__.py View on Github external
def test_dav_broken_item(self, s):
        item = Item('HAHA:YES')
        with pytest.raises((exceptions.Error, requests.exceptions.HTTPError)):
            s.upload(item)
        assert not list(s.list())
github pimutils / vdirsyncer / vdirsyncer / metasync.py View on Github external
import logging

from . import exceptions
from .storage.base import normalize_meta_value

logger = logging.getLogger(__name__)


class MetaSyncError(exceptions.Error):
    pass


class MetaSyncConflict(MetaSyncError):
    key = None


def metasync(storage_a, storage_b, status, keys, conflict_resolution=None):
    def _a_to_b():
        logger.info(f'Copying {key} to {storage_b}')
        storage_b.set_meta(key, a)
        status[key] = a

    def _b_to_a():
        logger.info(f'Copying {key} to {storage_a}')
        storage_a.set_meta(key, b)
github pimutils / vdirsyncer / vdirsyncer / exceptions.py View on Github external
existing_href = None


class WrongEtagError(PreconditionFailed):
    '''Wrong etag'''


class ReadOnlyError(Error):
    '''Storage is read-only.'''


class InvalidResponse(Error, ValueError):
    '''The backend returned an invalid result.'''


class UnsupportedMetadataError(Error, NotImplementedError):
    '''The storage doesn't support this type of metadata.'''


class CollectionRequired(Error):
    '''`collection = null` is not allowed.'''
github pimutils / vdirsyncer / vdirsyncer / exceptions.py View on Github external
'''Wrong etag'''


class ReadOnlyError(Error):
    '''Storage is read-only.'''


class InvalidResponse(Error, ValueError):
    '''The backend returned an invalid result.'''


class UnsupportedMetadataError(Error, NotImplementedError):
    '''The storage doesn't support this type of metadata.'''


class CollectionRequired(Error):
    '''`collection = null` is not allowed.'''
github pimutils / vdirsyncer / vdirsyncer / sync.py View on Github external
@contextlib.contextmanager
def _exclusive_transaction(conn):
    c = None
    try:
        c = conn.execute('BEGIN EXCLUSIVE TRANSACTION')
        yield c
        c.execute('COMMIT')
    except BaseException:
        if c is None:
            raise
        _, e, tb = sys.exc_info()
        c.execute('ROLLBACK')
        raise e.with_traceback(tb)


class SyncError(exceptions.Error):
    '''Errors related to synchronization.'''


class SyncConflict(SyncError):
    '''
    Two items changed since the last sync, they now have different contents and
    no conflict resolution method was given.

    :param ident: The ident of the item.
    :param href_a: The item's href on side A.
    :param href_b: The item's href on side B.
    '''

    ident = None
    href_a = None
    href_b = None
github pimutils / vdirsyncer / vdirsyncer / storage / dav.py View on Github external
def find_collections(self):
        rv = None
        try:
            rv = list(self._find_collections_impl(''))
        except (HTTPError, exceptions.Error):
            pass

        if rv:
            return rv
        dav_logger.debug('Given URL is not a homeset URL')
        return self._find_collections_impl(self.find_home())
github pimutils / vdirsyncer / vdirsyncer / storage / olddav.py View on Github external
def find_principal(self):
        try:
            return self._find_principal_impl('')
        except (HTTPError, exceptions.Error):
            dav_logger.debug('Trying out well-known URI')
            return self._find_principal_impl(self._well_known_uri)
github pimutils / vdirsyncer / vdirsyncer / exceptions.py View on Github external
class UserError(Error, ValueError):
    '''Wrapper exception to be used to signify the traceback should not be
    shown to the user.'''

    problems = None

    def __str__(self):
        msg = Error.__str__(self)
        for problem in self.problems or ():
            msg += f'\n  - {problem}'

        return msg


class CollectionNotFound(Error):
    '''Collection not found'''


class PairNotFound(Error):
    '''Pair not found'''

    pair_name = None


class PreconditionFailed(Error):
    '''
      - The item doesn't exist although it should
      - The item exists although it shouldn't
      - The etags don't match.

    Due to CalDAV we can't actually say which error it is.
github pimutils / vdirsyncer / vdirsyncer / exceptions.py View on Github external
def __str__(self):
        msg = Error.__str__(self)
        for problem in self.problems or ():
            msg += f'\n  - {problem}'

        return msg
github pimutils / vdirsyncer / vdirsyncer / exceptions.py View on Github external
class NotFoundError(PreconditionFailed):
    '''Item not found'''


class AlreadyExistingError(PreconditionFailed):
    '''Item already exists.'''
    existing_href = None


class WrongEtagError(PreconditionFailed):
    '''Wrong etag'''


class ReadOnlyError(Error):
    '''Storage is read-only.'''


class InvalidResponse(Error, ValueError):
    '''The backend returned an invalid result.'''


class UnsupportedMetadataError(Error, NotImplementedError):
    '''The storage doesn't support this type of metadata.'''


class CollectionRequired(Error):
    '''`collection = null` is not allowed.'''