geopython / OWSLib

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
https://owslib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
385 stars 275 forks source link

Error when accessing pycsw via oswlib in version 0.15.0 & 0.16.0. #440

Open bukun opened 6 years ago

bukun commented 6 years ago

First, I have build the pycsw server. Second, I write programe using oswlib to access pycsw server from another computer. The codes just as following:

csw = CatalogueServiceWeb('{svr}/pycsw/csw.py?'.format(svr = csw_server))
birds_query_like = PropertyIsLike('dc:title', '%{0}%'.format(keyw))
csw.getrecords2(constraints=[birds_query_like], maxrecords=20)

If using 0.13.0, 0.14.0, all the things goes fine. when using 0.15.0, 0.16.0, got the following error:

File "/home/bk/vpy_rre/lib/python3.5/site-packages/owslib/csw.py", line 376, in getrecords2
self._invoke()
File "/home/bk/vpy_rre/lib/python3.5/site-packages/owslib/csw.py", line 680, in _invoke
self._exml = etree.parse(BytesIO(self.response))
File "src/lxml/etree.pyx", line 3426, in lxml.etree.parse
File "src/lxml/parser.pxi", line 1856, in lxml.etree._parseDocument
File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseMemoryDocument
File "src/lxml/parser.pxi", line 1764, in lxml.etree._parseDoc
File "src/lxml/parser.pxi", line 1126, in lxml.etree._BaseParser._parseDoc
File "src/lxml/parser.pxi", line 600, in lxml.etree._ParserContext._handleParseResultDoc
File "src/lxml/parser.pxi", line 710, in lxml.etree._handleParseResult
File "src/lxml/parser.pxi", line 639, in lxml.etree._raiseParseError
File "<string>", line 6
lxml.etree.XMLSyntaxError: Opening and ending tag mismatch: hr line 5 and body, line 6, column 8

I add following lines at line 680 in csw.py (owslib 0.16.0).

        # parse result see if it's XML
        print('x' * 40)
        print(self.response)
        self._exml = etree.parse(BytesIO(self.response))

When running my programe, got( yes, It seems running twice by one accessing):

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b'<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- pycsw 2.3.dev0 -->\n  ... ... ... ...</csw:Capabilities>'
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b'<html>\r\n<head><title>404 Not Found</title></head>\r\n<body bgcolor="white">\r\n<center><h1>404 Not Found</h1></center>\r\n<hr><center>nginx/1.10.3</center>\r\n</body>\r\n</html>\r\n'

However, in oswlib 0.14.0, it would be( also running twice):

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b'<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- pycsw 2.3.dev0 -->\n ... ... ... ...</csw:Capabilities>'
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
b'<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n<!-- pycsw 2.3.dev0 -->\n<csw:GetRecordsResponse xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dct="http://purl.org/dc/terms/" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml" xmlns:ows="http://www.opengis.net/ows" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0.2" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2http://schemas.opengis.net/csw/2.0.2/CSW-discovery.xsd"><csw:SearchStatus timestamp="2018-04-16T22:51:54Z"/><csw:SearchResults nextRecord="0" numberOfRecordsMatched="0" numberOfRecordsReturned="0" recordSchema="http://www.opengis.net/cat/csw/2.0.2" elementSet="summary"/></csw:GetRecordsResponse>'
github-actions[bot] commented 1 week ago

This Issue has been inactive for 90 days. In order to manage maintenance burden, it will be automatically closed in 7 days.