Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Seedlink basic_client get_info failing when location and channel not in Seedlink reply #2808

Closed

Conversation

brenmous
Copy link
Contributor

What does this PR do?

In seedlink.basic_client.get_info, sets loc and cha as empty strings if they are not included in the Seedlink reply.

Why was it initiated? Any relevant Issues?

Current behaviour is to set loc and cha in station_cache as None if they aren't in the Seedlink reply. This causes the function to fail, as station_cache is then searched using fname, with loc and cha provided as name argument. A value of None for name will cause fname to raise, as it calls os.path.normpath(name), which expects a string. Empty strings get around this issue. This does mean missing codes will be returned as '' and it's up to the user to understand this means Seedlink didn't reply with the code, and that the stream may not be available.

PR Checklist

  • Correct base branch selected? master for new features, maintenance_... for bug fixes
  • This PR is not directly related to an existing issue (which has no PR yet).
  • If the PR is making changes to documentation, docs pages can be built automatically.
    Just remove the space in the following string after the + sign: "+ DOCS"
  • If any network modules should be tested for the PR, add them as a comma separated list
    (e.g. clients.fdsn,clients.arclink) after the colon in the following magic string: "+TESTS:clients.seedlink"
    (you can also add "ALL" to just simply run all tests across all modules)
  • All tests still pass.
  • Any new features or fixed regressions are be covered via new tests.
  • Any new or changed features have are fully documented.
  • Significant changes have been added to CHANGELOG.txt .
  • First time contributors have added your name to CONTRIBUTORS.txt .

The current behaviour is to set loc and cha as None in
station_cache if Seedlink doesn't include these subtags in its reply.

This causes get_info to break, as station_cache is then searched
through using fname, with loc and cha provided as the name
argument to fname. A value of None for name will raise, as fname
calls os.path.normpath, which expects a string.

If we set loc and cha as empty strings, the function can proceed.
Any missing location/channel codes will be returned as ''. This does
mean it's up to the user to understand that an empty string means
Seedlink didn't reply with the code, and that the stream may not be
available.
@ThomasLecocq
Copy link
Contributor

@brenmous this looks good. could you

  • rebase this on current master
  • what do you think about adding a warning.warn in the if not subtags: condition?

@megies
Copy link
Member

megies commented Mar 16, 2023

Hmm.. we could alternatively change this part of the code to let items with None values get through (or not) instead:

264             info = [(net, sta, loc, cha) for net, sta, loc, cha in                             
265                     self._station_cache if                                                     
266                     fnmatch.fnmatch(net, network or '*') and                                   
267                     fnmatch.fnmatch(sta, station or '*') and                                   
268                     fnmatch.fnmatch(loc, location or '*') and                                  
269                     fnmatch.fnmatch(cha, channel or '*')]                                      
270             return sorted(info)                                                                

What do you think @brenmous? That way we could still allow None values to indicate something for that network+station code is advertized but there is no data currently.

@megies megies added this to the 1.4.1 milestone Mar 16, 2023
@megies megies changed the base branch from maintenance_1.2.x to maintenance_1.4.x March 16, 2023 10:03
@megies
Copy link
Member

megies commented May 14, 2024

Somehow this didn't get listed in the 1.4.1 milestone by github like it should have and got left out..

@megies megies modified the milestones: 1.4.1, 1.5.0 May 14, 2024
@megies megies closed this in #3445 May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants