Open
Description
I am using the package python pyodata and getting parse issues when the meta-data is returned from the root ODATA location. I don't own the site, so the ODATA interface is controlled by riverbed software.
The error is (It look like it is looking for the DataService tag.
File "C:\Users\1455765990E\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyodata\v2\model.py", line 2752, in build
dataservices = next((child for child in edmx if etree.QName(child.tag).localname == 'DataServices'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\1455765990E\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyodata\v2\model.py", line 2752, in <genexpr>
dataservices = next((child for child in edmx if etree.QName(child.tag).localname == 'DataServices'))
^^^^^^^^^^^^^^^^^^^^^^
File "src\lxml\etree.pyx", line 1849, in lxml.etree.QName.__init__
File "src\lxml\apihelpers.pxi", line 1754, in lxml.etree._tagValidOrRaise
ValueError: Invalid tag name '<cyfunction Comment at 0x000001B5E651C5F0>'
and my code is: (I tired to tell it that it is a non-standard name space with a custom name space tag.
import requests
import pyodata
from pyodata.v2.model import PolicyFatal, PolicyWarning, PolicyIgnore, ParserError, Config
serviceURL = 'https://lms-odata.aternity.com/aternity.odata/v2.0/'
session = requests.Session()
session.auth = ('[email protected], 'pass')
session.verify = False
namespaces = {
'edmx': 'http://docs.oasis-open.org/odata/ns/edmx',
'edm': 'http://docs.oasis-open.org/odata/ns/edm',
'riverbed': 'www.riverbed.com/api/contract'
}
custom_config = Config(
xml_namespaces=namespaces,
default_error_policy=PolicyIgnore()
)
with open('metadata.xml', 'rb') as metaFile:
metadata = metaFile.read()
# Create instance of OData client
aternity = pyodata.Client(serviceURL, session, metadata=metadata, config=custom_config)
the start of the metadata file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:riverbed="www.riverbed.com/api/contract" Version="4.0" riverbed:aternity_api_version="2.0">
<!--\n\n \tAternity Api version : 2.0 \n\n-->
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="aternity.odata">
<EntityType Name="RAW_DATA_TOP_PROCESSES_VIRTUAL_APP_SERVER_SESSIONS_Type">
<Property Name="ACCOUNT_ID" Type="Edm.Int64" />
<Property Name="APPLICATION_NAME" Type="Edm.String" MaxLength="1024" />
<Property Name="APPLICATION_VERSION" Type="Edm.String" MaxLength="1024" />
<Property Name="MEASUREMENT_START_TIMESTAMP" Type="Edm.DateTimeOffset" />
<Property Name="PRC_CPU_UTIL_AVG" Type="Edm.Decimal" Precision="37" Scale="10" />
<Property Name="PRC_IO_READ_RATE" Type="Edm.Decimal" Precision="37" Scale="10" />
...