heigeo / climata

Python library for loading and iterating over climate and flow time series data (from ACIS/NOAA RCCs, CoCoRaHS, Hydromet/USBR, CNRFC ESP/NWS, SNOTEL/AWDB/NRCS, and NWIS/USGS)
http://climata.houstoneng.net
MIT License
83 stars 14 forks source link

MethodNotFound error #11

Closed bolliger32 closed 8 years ago

bolliger32 commented 8 years ago

I'm trying to run one of the quick sample codes from the Climate Viewer:

from climata.snotel import RegionDailyDataIO

data = RegionDailyDataIO( start_date="2013-01-01", end_date="2013-12-31", basin="18010202", parameter="SNWD", )

I'm getting the following MethodNotFound error: MethodNotFound: Method not found: 'AwdbWebService.AwdbWebServiceImplPort.nonzero'

Any thoughts here? Not sure if this is a bug or just user error, b/c I can't find any documentation.

sheppard commented 8 years ago

This looks like it might have been a temporary issue with the NRCS web service. Can you try it again?

bolliger32 commented 8 years ago

Interesting. I just tried again and unfortunately received the same error. Sorry I can't provide much more insight as I'm not too familiar with web services. Let me know if you have any other thoughts and I'm happy to try them. I'm using climata 0.4.0 and suds 0.6

sheppard commented 8 years ago

Ok, I was able to reproduce this in Python 2 (my previous check was with Python 3). It turns out it wasn't a web service issue, but rather an interesting interpretation of "not":

if not _server:
    _server = Client(...)

My intended interpretation: "if the server connection hasn't been initalized yet". However, Suds+Python 2 interpreted this to also mean "if the server object evaluates to a non-truthy value". This is what triggered the call to __nonzero__ which doesn't exist. I fixed the issue by changing it to if _server is None.

I also added a unit test for SNOTEL to the repository to ensure both Python versions are tested.

bolliger32 commented 8 years ago

aha! thank you for investigating this. I've had problems with "if not" for the same reasons before.