zMoooooritz / stapy

An easy to use SensorThings API Client written in Python
MIT License
6 stars 2 forks source link

Error messages when using STA without BasicAuth #27

Closed BWibo closed 2 years ago

BWibo commented 2 years ago

When running queries against STA without BasicAuth, I get error messages like this. Everything works as expected, but there is this console output:

import  stapy as sta
import datetime
import random
import sys

if len(sys.argv) > 1:
  api_URL = sys.argv[1]
  print("Using API URL: " + api_URL + "\n")
else:
  raise ValueError('No API URL passed to script!')

sta.set_sta_url(api_URL)

datastream_id = 169
phenomenonTime = datetime.datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S,%fZ")
result = random.randrange(0, 20)

obs = sta.Post.observation(
  phenomenonTime,
  result,
  datastream_id = datastream_id
)

results, times = sta.Query(sta.Entity.Observation).entity_id(obs).select("result", "phenomenonTime").get_data_sets()
print('Observation queried from server:\n\tphenomenonTime: %s\n\tresult: %d' % (times, results))

Console output:

CRITICAL:root:The provided key (STA_USR) does not exist in the config file
CRITICAL:root:The provided key (STA_PWD) does not exist in the config file
CRITICAL:root:The provided key (STA_USR) does not exist in the config file
CRITICAL:root:The provided key (STA_PWD) does not exist in the config file
Observation queried from server:
        phenomenonTime: 2022-03-11T09:45:49.321Z
        result: 16

Setting credentials should be optional, as it is not required for every STA. Hence, I think this should not be displayed, when no BasicAuth credentials set using: stapy.set_credentials({USR}, {PWD}).

zMoooooritz commented 2 years ago

Thanks for reporting again!

Will fix this in the next days, but as is stapy can be used anyway.