-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2353 from WikiWatershed/tt/bigcz-cuahsi-detail-va…
- Loading branch information
Showing
10 changed files
with
163 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
from __future__ import division | ||
|
||
from datetime import date, timedelta | ||
|
||
from rest_framework.exceptions import ValidationError | ||
|
||
from ulmo.cuahsi import wof | ||
|
||
DATE_FORMAT = '%m/%d/%Y' | ||
|
||
|
||
def details(wsdl, site): | ||
if not wsdl: | ||
raise ValidationError({ | ||
'error': 'Required argument: wsdl'}) | ||
|
||
if not site: | ||
raise ValidationError({ | ||
'error': 'Required argument: site'}) | ||
|
||
if not wsdl.upper().endswith('?WSDL'): | ||
wsdl += '?WSDL' | ||
|
||
return wof.get_site_info(wsdl, site) | ||
|
||
|
||
def values(wsdl, site, variable, from_date=None, to_date=None): | ||
if not wsdl: | ||
raise ValidationError({ | ||
'error': 'Required argument: wsdl'}) | ||
|
||
if not site: | ||
raise ValidationError({ | ||
'error': 'Required argument: site'}) | ||
|
||
if not variable: | ||
raise ValidationError({ | ||
'error': 'Required argument: variable'}) | ||
|
||
if not to_date: | ||
# Set to default value of today | ||
to_date = date.today().strftime(DATE_FORMAT) | ||
|
||
if not from_date: | ||
# Set to default value of one week ago | ||
from_date = (date.today() - | ||
timedelta(days=7)).strftime(DATE_FORMAT) | ||
|
||
if not wsdl.upper().endswith('?WSDL'): | ||
wsdl += '?WSDL' | ||
|
||
return wof.get_values(wsdl, site, variable, from_date, to_date) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ retry==0.9.1 | |
python-dateutil==2.6.0 | ||
suds==0.4 | ||
django_celery_results==1.0.1 | ||
ulmo==0.8.4 |