How to use the astroquery.vo_conesearch.exceptions.VOSError function in astroquery

To help you get started, we’ve selected a few astroquery 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 astropy / astroquery / astroquery / vo_conesearch / exceptions.py View on Github external
class BaseVOError(Exception):  # pragma: no cover
    """Base class for VO exceptions."""
    pass


class VOSError(BaseVOError):  # pragma: no cover
    """General VO service exception."""
    pass


class MissingCatalog(VOSError):  # pragma: no cover
    """VO catalog is missing."""
    pass


class DuplicateCatalogName(VOSError):  # pragma: no cover
    """VO catalog of the same title already exists."""
    pass


class DuplicateCatalogURL(VOSError):  # pragma: no cover
    """VO catalog of the same access URL already exists."""
    pass


class InvalidAccessURL(VOSError):  # pragma: no cover
    """Invalid access URL."""
    pass


class ConeSearchError(BaseVOError):  # pragma: no cover
    """General Cone Search exception."""
github astropy / astroquery / astroquery / vo_conesearch / vos_catalog.py View on Github external
long_descr = ':\n{0}'.format(info.content)
            else:
                long_descr = ''
            raise VOSError("Catalog server '{0}' returned status "
                           "'{1}'{2}".format(url, info.value, long_descr))

    out_tab = tab.get_first_table()

    kw_sr = [k for k in kwargs if 'sr' == k.lower()]
    if len(kw_sr) == 0:
        sr = 0
    else:
        sr = kwargs.get(kw_sr[0])

    if sr != 0 and out_tab.array.size <= 0:
        raise VOSError("Catalog server '{0}' returned {1} result".format(
            url, out_tab.array.size))

    out_tab.url = url  # Track the URL
    return out_tab
github astropy / astroquery / astroquery / vo_conesearch / validator / validate.py View on Github external
#
    # If using cached data, it will not detect network error
    # like the first run, but will raise exception.
    #
    # When SR is not 0, VOSError is raised for empty table.
    #
    if r['expected'] in ('good', 'incorrect') and r['nexceptions'] == 0:
        nexceptions = 0
        nwarnings = 0
        lines = []

        with warnings.catch_warnings(record=True) as warning_lines:
            try:
                vo_tab_parse(votable.table.parse(
                    r.get_vo_xml_path(), pedantic=False), r.url, {})
            except (E19, IndexError, VOSError) as e:  # pragma: no cover
                lines.append(str(e))
                nexceptions += 1
        lines = [str(x.message) for x in warning_lines] + lines

        warning_types = set()
        for line in lines:  # pragma: no cover
            w = votable.exceptions.parse_vowarning(line)
            if w['is_warning']:
                nwarnings += 1
            if w['is_exception']:
                nexceptions += 1
            warning_types.add(w['warning'])

        r['nwarnings'] += nwarnings
        r['nexceptions'] += nexceptions
        r['warnings'] += lines
github astropy / astroquery / astroquery / vo_conesearch / conesearch.py View on Github external
err_msg = str(e)
            vo_warn(W25, (url, err_msg))
            if not query_all and 'ConnectTimeoutError' in err_msg:
                n_timed_out += 1
        else:
            if query_all:
                result[r.url] = r
            else:
                result = r
                break

    if result is None:
        err_msg = 'None of the available catalogs returned valid results.'
        if n_timed_out > 0:
            err_msg += ' ({0} URL(s) timed out.)'.format(n_timed_out)
        raise VOSError(err_msg)

    return result
github astropy / astroquery / astroquery / vo_conesearch / vos_catalog.py View on Github external
kwargs : dict
            Keywords accepted by :meth:`add_catalog`.

        Returns
        -------
        db : `VOSDatabase`
            Merged database.

        Raises
        ------
        VOSError
            Invalid database or incompatible version.

        """
        if not isinstance(other, VOSDatabase):
            raise VOSError('{0} is not a VO database.'.format(other))

        if other.version != self.version:
            raise VOSError('Incompatible database version: {0}, '
                           '{1}'.format(self.version, other.version))

        db = VOSDatabase.create_empty()
        for old_db in (self, other):
            for key, cat in old_db.get_catalogs():
                db.add_catalog(key, cat, **kwargs)

        return db
github astropy / astroquery / astroquery / vo_conesearch / vos_catalog.py View on Github external
def __init__(self, tree):
        super(VOSCatalog, self).__init__(tree)

        for key in self._compulsory_keys:
            if key not in self._tree:
                raise VOSError('Catalog must have "{0}" key.'.format(key))
github astropy / astroquery / astroquery / vo_conesearch / exceptions.py View on Github external
__all__ = ['BaseVOError', 'VOSError', 'MissingCatalog', 'DuplicateCatalogName',
           'DuplicateCatalogURL', 'InvalidAccessURL', 'ConeSearchError']


class BaseVOError(Exception):  # pragma: no cover
    """Base class for VO exceptions."""
    pass


class VOSError(BaseVOError):  # pragma: no cover
    """General VO service exception."""
    pass


class MissingCatalog(VOSError):  # pragma: no cover
    """VO catalog is missing."""
    pass


class DuplicateCatalogName(VOSError):  # pragma: no cover
    """VO catalog of the same title already exists."""
    pass


class DuplicateCatalogURL(VOSError):  # pragma: no cover
    """VO catalog of the same access URL already exists."""
    pass


class InvalidAccessURL(VOSError):  # pragma: no cover
    """Invalid access URL."""
github astropy / astroquery / astroquery / vo_conesearch / vos_catalog.py View on Github external
Parameters
        ----------
        key : str
            Metadata key to delete.

        Raises
        ------
        KeyError
            Key not found.

        VOSError
            Key must exist in catalog, therefore cannot be deleted.

        """
        if key in self._compulsory_keys:
            raise VOSError('{0} must exist in catalog, therefore cannot be '
                           'deleted.'.format(key))
        del self._tree[key]
github astropy / astroquery / astroquery / vo_conesearch / vos_catalog.py View on Github external
Allow catalog with duplicate access URL?

        Raises
        ------
        VOSError
            Invalid catalog.

        DuplicateCatalogName
            Catalog with given name already exists.

        DuplicateCatalogURL
            Catalog with given access URL already exists.

        """
        if not isinstance(cat, VOSCatalog):
            raise VOSError('{0} is not a VO Service Catalog.'.format(cat))

        if name in self._catalogs:
            raise DuplicateCatalogName('{0} already exists.'.format(name))

        url = cat['url']
        names = self._url_keys[url]
        if len(names) > 0 and not allow_duplicate_url:
            raise DuplicateCatalogURL(
                '{0} already exists: {1}'.format(url, names))

        self._catalogs[name] = deepcopy(cat._tree)
        self._url_keys[url].append(name)