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

If TDSCatalog detects html, warn and try an XML link. #32

Merged
merged 1 commit into from
Jun 24, 2015

Conversation

dopplershift
Copy link
Member

Fixes #29.

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling 47d76e7 on dopplershift:html-warning into 39eddeb on Unidata:master.


# If we were given an HTML link, warn about it and try to fix to xml
if 'html' in resp.headers['content-type']:
import warnings
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the warnings package and not logging.warning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic that was suggested before was: logging for warnings of bad conditions that the user may want to know about, but can't do anything about; warnings module for warnings the user should address.

https://docs.python.org/3/howto/logging.html

Specifically: "warnings.warn() in library code if the issue is avoidable and the client application should be modified to eliminate the warning"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I remember now.

@dopplershift
Copy link
Member Author

My bigger question, is automatically trying a new URL and setting that on the TDSCatalog instance a good idea?

@landscape-bot
Copy link

Code Health
Code quality remained the same when pulling 47d76e7 on dopplershift:html-warning into 39eddeb on Unidata:master.

@lesserwhirls
Copy link
Collaborator

I think it's ok to try with xml if the url ends with html. It's a very common cut/paste error when trying to find a catalog url.

@dopplershift
Copy link
Member Author

Not just url endswith html, I replace all 'html' in the URL with 'xml'. This is important for URLs like: http://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/Global_onedeg/catalog.html?dataset=grib/NCEP/GFS/Global_onedeg/Best

@lesserwhirls
Copy link
Collaborator

Ah. Yes. I think that is still ok to do.

dopplershift added a commit that referenced this pull request Jun 24, 2015
If TDSCatalog detects html, warn and try an XML link.
@dopplershift dopplershift merged commit 5aac75c into Unidata:master Jun 24, 2015
@dopplershift dopplershift deleted the html-warning branch July 14, 2015 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants