GEOFON / fdsnws_scripts

Scripts for working with (EIDA) FDSN web services
GNU Lesser General Public License v3.0
4 stars 3 forks source link

fdsnws2sds: seems to compatible with Python 3.11 and beyond #11

Open petrrr opened 1 month ago

petrrr commented 1 month ago

While testing the packages, I realised that there might be some incompatibility of fdsnws2sds with the most recent versions of Python 3. The script seems to work correctly up to Python 3.10 but fails for 3.11 and 3.12.

Here the backtraces:

petr@kozel test-fdsnws-fetch % fdsnws2sds-3.11 -v --station ACER -s 2024-05-01 -e 2024-05-02 -o sds-311
getting routes from http://geofon.gfz-potsdam.de/eidaws/routing/1/query?service=station&station=ACER&starttime=2024-05-01&endtime=2024-05-02&format=post
getting data from https://webservices.ingv.it/fdsnws/station/1/query
got 904 bytes (text/plain) from https://webservices.ingv.it/fdsnws/station/1/query

In case of problems with your request, plese use the contact form at

    http://www.orfeus-eu.org/organization/contact/form/?recipient=EIDA

Traceback (most recent call last):
  File "/opt/local/bin/fdsnws2sds-3.11", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/fdsnwsscripts/fdsnws2sds.py", line 387, in main
    ts_used = random.sample(timespan.items(), min(len(timespan), options.max_lines))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/random.py", line 439, in sample
    raise TypeError("Population must be a sequence.  "
TypeError: Population must be a sequence.  For dicts or sets, use sorted(d).
petr@kozel test-fdsnws-fetch % fdsnws2sds-3.12 -v --station ACER -s 2024-05-01 -e 2024-05-02 -o sds-312
getting routes from http://geofon.gfz-potsdam.de/eidaws/routing/1/query?service=station&station=ACER&starttime=2024-05-01&endtime=2024-05-02&format=post
getting data from https://webservices.ingv.it/fdsnws/station/1/query
got 904 bytes (text/plain) from https://webservices.ingv.it/fdsnws/station/1/query

In case of problems with your request, plese use the contact form at

    http://www.orfeus-eu.org/organization/contact/form/?recipient=EIDA

Traceback (most recent call last):
  File "/opt/local/bin/fdsnws2sds-3.12", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/fdsnwsscripts/fdsnws2sds.py", line 387, in main
    ts_used = random.sample(timespan.items(), min(len(timespan), options.max_lines))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/random.py", line 413, in sample
    raise TypeError("Population must be a sequence.  "
TypeError: Population must be a sequence.  For dicts or sets, use sorted(d).
andres-h commented 1 month ago

Does https://github.com/GEOFON/fdsnws_scripts/commit/6054e3cafd3bfd5e071b304a586eafa939b2e367 fix the problem?