Exemplo n.º 1
0
def test_is_wms(url):
    """
    Checks if the provided URL actually points to a Web Map Service.
    Uses owslib WMS reader to parse the response.
    :param url:
    :return:
    """

    try:
        capabilities_url = wms.WMSCapabilitiesReader().capabilities_url(url)
        res = urllib2.urlopen(capabilities_url, None, 10)
        xml = res.read()
        s = wms.WebMapService(url, xml=xml)
        return isinstance(s.contents, dict) and s.contents != {}
    except Exception, e:
        log.error('WMS check for %s failed with exception: %s' % (url, str(e)))
Exemplo n.º 2
0
    def _is_wms(self, url):
        '''
        Checks if the provided URL actually points to a Web Map Service.
        Uses owslib WMS reader to parse the response.
        '''
        try:
            capabilities_url = wms.WMSCapabilitiesReader().capabilities_url(
                url)
            res = urlopen(capabilities_url, None, 10)
            xml = res.read()

            s = wms.WebMapService(url, xml=xml)
            return isinstance(s.contents, dict) and s.contents != {}
        except Exception as e:
            log.error('WMS check for %s failed with exception: %s' %
                      (url, six.text_type(e)))
        return False
Exemplo n.º 3
0
    def _is_wms(self, url):
        '''
        Checks if the provided URL actually points to a Web Map Service.
        Uses owslib WMS reader to parse the response.
        '''

        try:
            capabilities_url = wms.WMSCapabilitiesReader().capabilities_url(url)
            res = requests.get(capabilities_url, timeout=10)
            xml = res.text

            s = wms.WebMapService(url, xml=xml)
            raise Exception('is_wms: {}'.format(s.contents))
            return isinstance(s.contents, dict) and s.contents != {}
        except Exception as e:
            logger.error('WMS check for %s failed with exception: %s' % (url, str(e)))
        return False