Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
geomag-algorithms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ghsc
National Geomagnetism Program
geomag-algorithms
Commits
f829d30c
Commit
f829d30c
authored
5 years ago
by
Travis Rivers
Committed by
Jeremy M Fee
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
updates
parent
2d3f92c4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
geomagio/webservice/data.py
+8
-11
8 additions, 11 deletions
geomagio/webservice/data.py
with
8 additions
and
11 deletions
geomagio/webservice/data.py
+
8
−
11
View file @
f829d30c
...
@@ -58,7 +58,7 @@ def get_data():
...
@@ -58,7 +58,7 @@ def get_data():
validate_query
(
parsed_query
)
validate_query
(
parsed_query
)
except
Exception
as
e
:
except
Exception
as
e
:
exception
=
str
(
e
)
exception
=
str
(
e
)
error_body
=
format_error
(
400
,
exception
,
parsed_query
,
request
)
error_body
=
format_error
(
400
,
exception
)
return
error_body
return
error_body
try
:
try
:
...
@@ -66,7 +66,7 @@ def get_data():
...
@@ -66,7 +66,7 @@ def get_data():
return
format_timeseries
(
timeseries
,
parsed_query
)
return
format_timeseries
(
timeseries
,
parsed_query
)
except
Exception
as
e
:
except
Exception
as
e
:
exception
=
str
(
e
)
exception
=
str
(
e
)
error_body
=
format_error
(
500
,
exception
,
parsed_query
,
request
)
error_body
=
format_error
(
500
,
exception
)
return
error_body
return
error_body
...
@@ -116,10 +116,10 @@ class WebServiceQuery(object):
...
@@ -116,10 +116,10 @@ class WebServiceQuery(object):
self
.
output_format
=
output_format
self
.
output_format
=
output_format
def
format_error
(
status_code
,
exception
,
parsed_query
,
request
):
def
format_error
(
status_code
,
exception
):
"""
Assign error_body value based on error format.
"""
"""
Assign error_body value based on error format.
"""
if
parsed_query
.
output_format
==
'
json
'
:
if
request
.
args
.
get
(
"
output_format
"
)
==
'
json
'
:
return
Response
(
return
Response
(
json_error
(
status_code
,
exception
,
request
.
url
),
json_error
(
status_code
,
exception
,
request
.
url
),
mimetype
=
"
application/json
"
)
mimetype
=
"
application/json
"
)
...
@@ -200,7 +200,7 @@ def get_timeseries(query):
...
@@ -200,7 +200,7 @@ def get_timeseries(query):
return
timeseries
return
timeseries
def
iaga2002_error
(
code
,
message
,
request_args
):
def
iaga2002_error
(
code
,
message
):
"""
Format iaga2002 error message.
"""
Format iaga2002 error message.
Returns
Returns
...
@@ -227,7 +227,7 @@ Service Version:
...
@@ -227,7 +227,7 @@ Service Version:
return
error_body
return
error_body
def
json_error
(
code
,
message
,
url
):
def
json_error
(
code
,
message
):
"""
Format json error message.
"""
Format json error message.
Returns
Returns
...
@@ -243,11 +243,10 @@ def json_error(code, message, url):
...
@@ -243,11 +243,10 @@ def json_error(code, message, url):
"
metadata
"
:
{
"
metadata
"
:
{
"
status
"
:
code
,
"
status
"
:
code
,
"
generated
"
:
date
,
"
generated
"
:
date
,
"
url
"
:
url
,
"
url
"
:
request
.
url
,
"
title
"
:
status_message
,
"
title
"
:
status_message
,
"
error
"
:
message
"
error
"
:
message
}
}
}
}
return
dumps
(
error_dict
,
return
dumps
(
error_dict
,
sort_keys
=
True
).
encode
(
'
utf8
'
)
sort_keys
=
True
).
encode
(
'
utf8
'
)
...
@@ -287,13 +286,11 @@ def parse_query(query):
...
@@ -287,13 +286,11 @@ def parse_query(query):
start_time
=
query
.
get
(
'
starttime
'
)
start_time
=
query
.
get
(
'
starttime
'
)
if
not
start_time
:
if
not
start_time
:
now
=
datetime
.
now
()
now
=
datetime
.
now
()
today
=
UTCDateTime
(
start_time
=
UTCDateTime
(
year
=
now
.
year
,
year
=
now
.
year
,
month
=
now
.
month
,
month
=
now
.
month
,
day
=
now
.
day
,
day
=
now
.
day
,
hour
=
0
)
hour
=
0
)
start_time
=
today
try
:
try
:
end_time
=
UTCDateTime
(
query
.
get
(
"
endtime
"
))
end_time
=
UTCDateTime
(
query
.
get
(
"
endtime
"
))
except
:
except
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment