INGV / qquake

A plugin for QGIS 3.x that relies on web services for loading seismological data
https://www.emidius.eu/qquake/
GNU General Public License v3.0
7 stars 3 forks source link

Python error when the service return http error 204 #73

Closed MarioLocati closed 11 months ago

MarioLocati commented 1 year ago

When a fdsn (event, macroseismic o station) service returns an https error code 204 "no content", qquake generate a python error.

To reproduce the issue:

Below the stack trace of the generated by the Python error

IndexError: list index out of range 
Traceback (most recent call last):
  File "/home/mario/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qquake/gui/qquake_dialog.py", line 966, in _fetcher_finished
    layer = self.fetcher.create_event_layer()
  File "/home/mario/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qquake/fetcher.py", line 774, in create_event_layer
    return self.events_to_layer(self.result, self.preferred_origins_only, self.preferred_magnitudes_only)
  File "/home/mario/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qquake/fetcher.py", line 618, in events_to_layer
    vl = self._create_empty_event_layer()
  File "/home/mario/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qquake/fetcher.py", line 569, in _create_empty_event_layer
    vl.dataProvider().addAttributes(self.result.to_event_fields(self.output_fields))
  File "/home/mario/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qquake/basic_text/basic_text_parser.py", line 186, in to_event_fields
    fields.append(QgsField(self.headers[0], QVariant.String))
IndexError: list index out of range

See the screenshot below image

MarioLocati commented 11 months ago

Solved by these commits https://github.com/INGV/qquake/commit/7ebb5180ecc5bf14d77fa48c883fa6f61b0b02ea and https://github.com/INGV/qquake/commit/84c3ae2c16f8264f1cb561de65fd2b41c5d76650

Thank you @GiorgioMariaDeSantis !