From f0e2fdb470d72b7bd2bebf89ef906c480f49bdb8 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Fri, 7 Dec 2018 13:06:39 +0100 Subject: [PATCH] [bugfix]/[improvement] handle station id lacking location, related to #266 Unpack depending on length of station id after split, if something unexpected happens, initialise with default values. This is related to https://ariadne.geophysik.ruhr-uni-bochum.de/trac/PyLoT/ticket/266. This should fix the missing station information in the title of the TuneAutopicker waveform plot. --- pylot/core/util/widgets.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 69a17b3c..42339f34 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -3427,7 +3427,6 @@ class TuneAutopicker(QWidget): return str(self.stationBox.currentText()).split('.')[1] def get_current_station_id(self): - print(self.stationBox, self.stationBox.currentText()) return str(self.stationBox.currentText()) @staticmethod @@ -3445,15 +3444,18 @@ class TuneAutopicker(QWidget): self.pdlg_widget = None return self.load_wf_data() - try: - network, station, location, channel = self.get_current_station_id().split(".") - except ValueError as e: - # not enough values to unpack, initialize default values - vmsg = '{0}'.format(e) - print(vmsg) + station_id_list = self.get_current_station_id().split(".") + # this sometimes only contains network.station. + if len(station_id_list) == 3: + # location is empty string + network, station, location = station_id_list + elif len(station_id_list) == 4: + # location contains text + network, station, location, _ = station_id_list + else: station = self.get_current_station() - location = None network = None + location = None wfdata = self.data.getWFData() metadata = self.parent().metadata