tagreader-python
tagreader-python copied to clipboard
Searching for "11#35-DENS" on MO-IP21AB causes Requests.JSONDecodeError
Using the following code to search for 11#35-DENS causes Requests.JSONDecodeError.
import os
import datetime
import tagreader
def connect_to_aspen():
print("Venter på svar frå aspen")
API = "aspenone"
sources = tagreader.list_sources(API)
if "MO-IP21AB" not in sources:
print("Kunne ikkje koble til MO-IP21AB")
os._exit(0)
else:
source = "MO-IP21AB"
client = tagreader.IMSClient(source, API)
client.connect()
return client
if __name__ == "__main__":
pp = "11#35-DENS"
end = datetime.date.today()
start = end + datetime.timedelta(days=-30)
client = connect_to_aspen()
m = client.search(pp)
print(m)
Backtrace:
Traceback (most recent call last):
File "C:\Users\hsysl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 972, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "f:\tettleiksmeister\main.py", line 24, in <module>
m = client.search(pp)
File "C:\Users\hsysl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tagreader\clients.py", line 273, in search
return self.handler.search(tag, desc)
File "C:\Users\hsysl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tagreader\web_handlers.py", line 349, in search
description = self._get_tag_description(tagname)
File "C:\Users\hsysl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tagreader\web_handlers.py", line 403, in _get_tag_description
j = res.json()
File "C:\Users\hsysl\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\requests\models.py", line 976, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Hi Håvard,
I am trying to replicate the error on my side, but I am only getting an empty list output.

If you search for:
pp="*"
Do you get the same error? I am trying to deduct if it's tag specific or search function doesn't work on your end.
Adam
Hi,
searching for pp="*" causes the same error. Searching for pp="11-TI-050", a tag that does not exist returns an empty list.
Hi,
I don't have access to the MO asset as we have only looked after the offshore assets. I will rise a request for access so I can replicate the error and see what value is the server passing over to cause the error.
Hi,
I got access to the PI of MO asset. I am able to search and see the tag. However, a part of the code is sending a request to the server to get_tag_description and getting an error message returned from server. Will investigate further, however, it might be PI server issue rather than tagreader.
Hi,
There was a server side error coming in when calling descriptions. The code should now search without crashing with next update.
Kind Regards, Adam