def scan_files_in_thread(self, param_dict): """ """ try: # Check if thread is running. if self.thread_object: if self.thread_object.is_alive(): app_utils.Logging().warning( 'Wave file scanner is already running. Please try again later.' ) return # Use a thread to relese the user. item_id_list = param_dict.get('item_id_list', []) low_freq_hz = param_dict.get('low_frequency_hz', 15000.0) high_freq_hz = param_dict.get('high_frequency_hz', None) min_amp_level_dbfs = param_dict.get('min_amp_level_dbfs', None) min_amp_level_relative = param_dict.get('min_amp_level_relative', None) self._scan_files(item_id_list, low_freq_hz, high_freq_hz, min_amp_level_dbfs, min_amp_level_relative) # self.thread_object = threading.Thread(target=self._scan_files, # args=(item_id_list, # low_freq_hz, high_freq_hz, # min_amp_level_dbfs, min_amp_level_relative # )) # self.thread_object.start() except Exception as e: app_utils.Logging().warning( 'Failed to scan wave files. Exception: ' + str(e))
def plot_map(self): """ Use a thread to relese the user. """ try: workspace = app_core.DesktopAppSync().get_workspace() survey = app_core.DesktopAppSync().get_selected_survey() item_id = app_core.DesktopAppSync().get_selected_item_id( item_type='wavefile') item_metadata = app_core.DesktopAppSync().get_metadata_dict() item_title = item_metadata.get('item_title', '') # try: # Check if thread is running. if not self.plot_map_thread: # self.plot_map_active = True self.plot_map_thread = threading.Thread( target=self.run_map_plotter, args=()) self.plot_map_thread.start() except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) app_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e)) plot_map_dict = {} plot_map_dict['workspace'] = workspace plot_map_dict['survey'] = survey plot_map_dict['item_id'] = item_id plot_map_dict['item_title'] = item_title # while self.plot_map_queue.qsize() > 1: try: self.plot_map_queue.get_nowait() except queue.Empty: break # Exits while loop. # self.plot_map_queue.put(plot_map_dict) except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) app_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def visibility_changed(self, visible): """ """ try: if visible: self.last_used_latitude = 0.0 self.last_used_longitude = 0.0 self.last_used_degree_range = 0.0 QtCore.QTimer.singleShot(100, self.plot_map) except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) app_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _load_item_data(self): """ """ try: self._items_model.clear() h5_wavefiles = hdf54bats.Hdf5Wavefiles(self.dir_path, self.survey_name) from_top_node = '' nodes = h5_wavefiles.get_child_nodes(from_top_node) for node_key in sorted(nodes): node_dict = nodes.get(node_key, {}) node_item_id = node_dict.get('item_id', '') node_item_type = node_dict.get('item_type', '') if node_item_type == 'wavefile': item = QtGui.QStandardItem(node_item_id) item.setCheckState(QtCore.Qt.Unchecked) item.setCheckable(True) self._items_model.appendRow(item) # nodes = h5wavefile.get_child_nodes(item_id) # for node_key in sorted(nodes): # node_dict = nodes.get(node_key, {}) # node_row = [] # node_item_id = node_dict.get('item_id', '') # node_item_type = node_dict.get('item_type', '') # node_row.append(node_item_id) # node_row.append(node_item_type) # node_row.append(node_dict.get('item_title', '')) # dataset_table.append_row(node_row) # self._items_model.clear() # wave = hdf54bats.Hdf5Wavefiles(self.dir_path, self.survey_name) # # from_top_node = '' # wavefiles_dict = wave.get_wavefiles(from_top_node) # # for wave_id in sorted(wavefiles_dict): # # self.groupid_combo.addItem(event_group) # item = QtGui.QStandardItem(wave_id) # item.setCheckState(QtCore.Qt.Unchecked) # item.setCheckable(True) # self._items_model.appendRow(item) # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) app_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def _delete_marked_items(self): """ """ try: try: h5_wavefiles = hdf54bats.Hdf5Wavefiles(self.dir_path, self.survey_name) for rowindex in range(self._items_model.rowCount()): item = self._items_model.item(rowindex, 0) if item.checkState() == QtCore.Qt.Checked: item_id = str(item.text()) h5_wavefiles.remove_wavefile(item_id, recursive=True) finally: self.accept() # Close dialog box. # except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) app_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def run_map_plotter(self): """ """ try: try: while self.plot_map_active: queue_item = self.plot_map_queue.get() if queue_item == False: # Exit. self.plot_map_active = False continue # if self.isVisible(): self.update_map() finally: self.plot_map_thread = None except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) app_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))
def update_surveys_dict(self): """ """ self.survey_dict = {} if self.workspace: try: if not pathlib.Path(self.workspace).exists(): return h5_ws = hdf54bats.Hdf5Workspace(self.workspace) # h5_list = h5_ws.get_h5_list() for h5_file_key in sorted(h5_list.keys()): h5_file_dict = h5_list[h5_file_key] h5_dict = {} h5_dict['h5_file'] = h5_file_dict['name'] h5_dict['h5_title'] = h5_file_dict['title'] h5_dict['h5_filepath'] = h5_file_dict['f5_filepath'] # self.survey_dict[h5_file_dict['name']] = h5_dict except Exception as e: debug_info = self.__class__.__name__ + ', row ' + str( sys._getframe().f_lineno) app_utils.Logging().error('Exception: (' + debug_info + '): ' + str(e))