obspy/obspy — pull request #777 by bmorg (2014-04-16 02:34:19+00:00)
Title: Fixing multiple SeedLink bugs

This pull request fixes multiple bugs in `obspy.seedlink`.

-----

**# 1:** A typo in `SeedLinkConnection` prevented logging from working correctly (fda29ae).

-----

**# 2:** Some exception handling was catching `Exception` while implicitly expecting `SeedLinkException`, e.g.:

```python
try:
[...]
except Exception as e:
logger.error(e.value)
```

Python exceptions don't generally have a `value` attribute.

Fixed in 03ad616.

-----

**# 3:** When selecting multiple streams in multi-station mode, all calls to `addStream` but the first used to fail, preventing the connection from correctly initializing (2f5583b).

To trigger the behavior:

```python
from obspy.seedlink.slclient import SLClient

client = SLClient(loglevel='DEBUG')
client.slconn.setSLAddress('geofon.gfz-potsdam.de:18000')

client.slconn.addStream('BW', 'RJOB', 'EHZ', seqnum=-1, timestamp=None)
client.slconn.addStream('BW', 'RJOB', 'EHN', seqnum=-1, timestamp=None)

client.run()
```

Output:

```
DEBUG: obspy.seedlink [geofon.gfz-potsdam.de:18000]:primary loop pass 0
INFO: obspy.seedlink [geofon.gfz-potsdam.de:18000]:network socket opened
DEBUG: obspy.seedlink [geofon.gfz-potsdam.de:18000]:sending: HELLO
INFO: obspy.seedlink [geofon.gfz-potsdam.de:18000]:connected to: 'SeedLink v3.1 (2013.231)'
DEBUG: obspy.seedlink [geofon.gfz-potsdam.de:18000]:sending: STATION RJOB BW
DEBUG: obspy.seedlink [geofon.gfz-potsdam.de:18000]:response: station is OK (selected)
DEBUG: obspy.seedlink [geofon.gfz-potsdam.de:18000]:sending: SELECT EHZ
DEBUG: obspy.seedlink [geofon.gfz-potsdam.de:18000]:response: selector EHZ is OK
ERROR: obspy.seedlink [geofon.gfz-potsdam.de:18000]:cannot concatenate 'str' and 'list' objects
ERROR: obspy.seedlink [geofon.gfz-potsdam.de:18000]:negotiation with remote SeedLink failed: 'no stations accepted'
INFO: obspy.seedlink [geofon.gfz-potsdam.de:18000]:network socket closed
```

-----

**# 4:** An instantiation of a `SeedLinkException` was missing an argument (d95f314).

-----

**# 5:** Calling `SeedLinkConnection.addStream` with `selectors_str=None` (as advertised in the docstring) raised an exception.

This is fixed in 7734130.

IMHO accepting empty selectors here is of limited practical use anyway. Without manually fiddling with the created empty `SLNetStation`, this will usually lead to the following error being raised in `SeedLinkConnection.negotiateStation`:

```
negotiation with remote SeedLink failed: 'no stations accepted'
```

-----

Some other issues with the module I could not fix quickly, due to the missing separation of protocol and client layers.