# Path: pyweed/signals.py
# class SignalingThread(QtCore.QThread):
#     """
#     Mixin that serves to standardize how we use signals to pass information around
#     """
#     # Signal to indicate success
#     done = QtCore.pyqtSignal(object)
# 
#     def __del__(self):
#         self.wait()
# 
# class SignalingObject(QtCore.QObject):
#     """
#     Mixin for other objects that manage threaded work, and need to signal completion
#     """
#     # Signal to indicate success
#     done = QtCore.pyqtSignal(object)
# 
# Path: pyweed/dist_from_events.py
# def get_combined_locations(points, distance):
#     """
#     Given a set of points and a distance, return a reasonable set of
#     bounding areas covering everything within that distance of any point.
#     """
#     # Very simple implementation, try to draw a box around all points
#     box = LatLonBox(distance)
# 
#     if not points:
#         return []
# 
#     for lat, lon in points:
#         box.add_point(lat, lon)
#     LOGGER.info("Combined points into: %s", box)
#     return [box]
# 
# class CrossBorderException(Exception):
#     pass


import logging
import concurrent.futures
    import doctest
from pyweed.signals import SignalingThread, SignalingObject
from obspy.core.inventory.inventory import Inventory
from pyweed.pyweed_utils import get_service_url, CancelledException, DataRequest, get_distance
from PyQt5 import QtCore
from pyweed.dist_from_events import get_combined_locations, CrossBorderException
    Mazama Science, IRIS
:license:
    GNU Lesser General Public License, Version 3
    (http://www.gnu.org/copyleft/lesser.html)
"""

from __future__ import (absolute_import, division, print_function)


LOGGER = logging.getLogger(__name__)


def load_stations(client, parameters):
    """
    Execute one query for station metadata. This is a standalone function so we can
    run it in a separate thread.
    """
    try:
        LOGGER.info('Loading stations: %s', get_service_url(client, 'station', parameters))
        return client.get_stations(**parameters)
    except Exception as e:
        # If no results found, the client will raise an exception, we need to trap this
        # TODO: this should be much cleaner with a fix to https://github.com/obspy/obspy/issues/1656
        if str(e).startswith("No data"):
            LOGGER.warning("No stations found! Your query may be too narrow.")
            return Inventory([], 'INTERNAL')
        else:
            raise



# Path: pyweed/signals.py
# class SignalingThread(QtCore.QThread):
#     """
#     Mixin that serves to standardize how we use signals to pass information around
#     """
#     # Signal to indicate success
#     done = QtCore.pyqtSignal(object)
# 
#     def __del__(self):
#         self.wait()
# 
# class SignalingObject(QtCore.QObject):
#     """
#     Mixin for other objects that manage threaded work, and need to signal completion
#     """
#     # Signal to indicate success
#     done = QtCore.pyqtSignal(object)
# 
# Path: pyweed/dist_from_events.py
# def get_combined_locations(points, distance):
#     """
#     Given a set of points and a distance, return a reasonable set of
#     bounding areas covering everything within that distance of any point.
#     """
#     # Very simple implementation, try to draw a box around all points
#     box = LatLonBox(distance)
# 
#     if not points:
#         return []
# 
#     for lat, lon in points:
#         box.add_point(lat, lon)
#     LOGGER.info("Combined points into: %s", box)
#     return [box]
# 
# class CrossBorderException(Exception):
#     pass


# Path: pyweed/stations_handler.py
import logging
import concurrent.futures
    import doctest
from pyweed.signals import SignalingThread, SignalingObject
from obspy.core.inventory.inventory import Inventory
from pyweed.pyweed_utils import get_service_url, CancelledException, DataRequest, get_distance
from PyQt5 import QtCore
from pyweed.dist_from_events import get_combined_locations, CrossBorderException

    Mazama Science, IRIS
:license:
    GNU Lesser General Public License, Version 3
    (http://www.gnu.org/copyleft/lesser.html)
"""

from __future__ import (absolute_import, division, print_function)


LOGGER = logging.getLogger(__name__)


def load_stations(client, parameters):
    """
    Execute one query for station metadata. This is a standalone function so we can
    run it in a separate thread.
    """
    try:
        LOGGER.info('Loading stations: %s', get_service_url(client, 'station', parameters))
        return client.get_stations(**parameters)
    except Exception as e:
        # If no results found, the client will raise an exception, we need to trap this
        # TODO: this should be much cleaner with a fix to https://github.com/obspy/obspy/issues/1656
        if str(e).startswith("No data"):
            LOGGER.warning("No stations found! Your query may be too narrow.")
            return Inventory([], 'INTERNAL')
        else:
            raise



class StationsLoader(SignalingThread):