Coder Social home page Coder Social logo

python-zamg's People

Contributors

cdce8p avatar dependabot[bot] avatar dlang-geosphereat avatar killer0071234 avatar tklecka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

python-zamg's Issues

Add coverage badge

Is your feature request related to a problem? Please describe.
We want to add the coverage badge

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Upcoming domain change to geosphere.at

Hi @killer0071234 !

Since January 2023 the organizations ZAMG and GBA merged to Geosphere Austria. As a result, the API provided currently under https://dataset.api.hub.zamg.ac.at/v1 will move to a new domain => https://dataset.api.hub.geosphere.at/v1 (not yet public)

This change also comes with infrastructure changes behind the scenes (which will lead to better performance in the future!). In order to not maintain multiple environments we are considering HTTP 301 redirects. However, this would break your package, as you are not following redirects: https://github.com/killer0071234/python-zamg/blob/main/src/zamg/zamg.py#L80

Estimated timeline

The new domain will be public and the new canonical URL this summer, ideally July.

Changes

For users only the domain will change. Any other changes in the future will be announced ahead of time to allow adjustments.

Solution

Is there a specific reason why you don't follow redirects? This would be an easy solution for the upcoming change, that doesn't need a lot of coordination.

Set of used station parameter to read, instead of reading all of them

Is your feature request related to a problem? Please describe.
There shall be a possibility to set station parameter to read

Describe the solution you'd like
_station_parameters external accessable

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Exceptions instead of custom structures

Is your feature request related to a problem? Please describe.
If there are any issues during update return a exception instead of strange return values

Describe the solution you'd like
Raise of custom exceptions if something goes wrong

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Failed session.get raises Exception

Version of zamg

v0.1.1

Describe the bug

a call of session.get can raise TimeoutError or ClientConnectorError if the server is not reachable or the hostname is invalid

Debug log

Traceback (most recent call last):
  File "/workspaces/python-zamg/control.py", line 31, in <module>
    asyncio.run(main())
  File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/workspaces/python-zamg/control.py", line 11, in main
    data = await zamg.closest_station(46.99, 15.499)
  File "/workspaces/python-zamg/src/zamg/zamg.py", line 97, in closest_station
    if (stations := await self.zamg_stations()) is None:
  File "/workspaces/python-zamg/src/zamg/zamg.py", line 60, in zamg_stations
    response = await self.session.get(
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client.py", line 535, in _request
    conn = await self._connector.connect(
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/connector.py", line 1166, in _create_direct_connection
    raise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host dataset.api.hub.zamg11.ac.at:443 ssl:default [Name or service not known]

TypeError in except

Version of zamg

0.1.1

Describe the bug

if the variable self._station_id is none, the except will generate a TypeError exception.

Debug log

Relevant part of log:

  File "/usr/local/lib/python3.9/site-packages/zamg/zamg.py", line 132, in get_station_name
    return "Unknown station with id: " + self._station_id
TypeError: can only concatenate str (not "NoneType") to str

Reduce number of calls to ZAMG servers

Version of zamg

0.2.1

Describe the bug

Unfortunately, I cannot provide a detailed description, but please check your logic for calls to ZAMG servers. We receive calls to both the metadata and data endpoints far more often than every 10 min. With an increasing number of users of this plugin, this is putting a heavy load on our servers.

Debug log

Not applicable.

Changed/Wrong timestamp format

Version of zamg

0.1.1

Describe the bug

Looks like ZAMG changed their timestamp format yesterday. They removed the seconds.
I'm not sure if this is a permanent change and therefore worth fixing.
At least I can't find any change logs from ZAMG.

Of course, that also breaks the home assistant integration, see home-assistant/core#83988

Debug log

This is a trace from home assistant:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 225, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/components/zamg/coordinator.py", line 44, in _async_update_data
    self.data["last_update"] = self.zamg.last_update
  File "/usr/local/lib/python3.10/site-packages/zamg/zamg.py", line 142, in last_update
    return datetime.strptime(
  File "/usr/local/lib/python3.10/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
  File "/usr/local/lib/python3.10/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '2022-12-14T23:00+00:00' does not match format '%Y-%m-%dT%H:%M:%S+00:00'

Using the new Zamg Datahub Api?

Is your feature request related to a problem? Please describe.
The problem is, that with the current Api (OGD) there are only a few stations availible.

Describe the solution you'd like
Using the new Api provided by Zamg, would support all stations. (Doku, Example)

Describe alternatives you've considered
I think there is no alternative solution.?

Additional context
Example Request:
https://dataset.api.hub.zamg.ac.at/v1/station/current/tawes-v1-10min?parameters=TL,P,FFAM&station_ids=11035
to request Temperature, Pressure and Windspeed.

Zamg is closing aiohttp session on HA

Version of zamg

Describe the bug

A opened aiohttp session shall not closed by python lib

Debug log


Detected integration that closes the Home Assistant aiohttp session. Please report issue for zamg using this method at homeassistant/components/zamg/coordinator.py, line 44: device = await self.zamg.update()

Update error

Version of zamg v0.1.0

Describe the bug

a call of client.update() without leading call of client.zamg_stations() causes a error.
caused by a empty variable self._station_parameters

Debug log

can only concatenate str (not "NoneType") to str

Unclosed client session

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x0000020CFE6C6550>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x0000020CFE73C520>, 352568.39)]']
connector: <aiohttp.connector.TCPConnector object at 0x0000020CFF040C10>
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x0000020CFF022220>
transport: <_ProactorSocketTransport fd=932 read=<_OverlappedFuture cancelled>>
Traceback (most recent call last):
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 684, in _process_write_backlog
self._transport.write(chunk)
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 359, in write
self._loop_writing(data=bytes(data))
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 395, in _loop_writing
self._write_fut = self._loop._proactor.send(self._sock, data)
AttributeError: 'NoneType' object has no attribute 'send'
Exception ignored in: <function _SSLProtocolTransport.del at 0x0000020CFE5AC1F0>
Traceback (most recent call last):
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 321, in del
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 316, in close
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 593, in _start_shutdown
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 598, in _write_appdata
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 706, in _process_write_backlog
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 720, in _fatal_error
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 151, in _force_close
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
File "C:\Users\Arnold\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed

kommm da leider nicht weiter? (Beispielcode)
Aber ein super Tool ist die Klasse :-)

Danke Lg

Add version and url to user agent api request

Is your feature request related to a problem? Please describe.
It is probably also helpful to have more meaningful information about the plugin/user-agent. Please include an URL (e.g. this github repo) and the version number of this integration. (Other best practices regarding user agents: https://developers.whatismybrowser.com/learn/browser-detection/user-agents/user-agent-best-practices) This can help with analyzing such situations.

Describe the solution you'd like
The header has now as user agent python-zamg. It shall also include the api version and url. Prefered url is this repo.

Describe alternatives you've considered

Additional context
Originally posted by @Langdi in #104 (comment)

Add possibility to ignore ssl error

Is your feature request related to a problem? Please describe.
Possibility to disable ssl error check

Describe the solution you'd like
Add parameter verify_ssl to lib

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.