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
2f4c9b59
Commit
2f4c9b59
authored
6 years ago
by
Jeremy M Fee
Committed by
Claycomb, Abram Earl
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update WebService to use configurable error stream, to reduce test noise
parent
35dd0ae5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
geomagio/WebService.py
+5
-3
5 additions, 3 deletions
geomagio/WebService.py
test/WebService_test.py
+1
-1
1 addition, 1 deletion
test/WebService_test.py
with
6 additions
and
4 deletions
geomagio/WebService.py
+
5
−
3
View file @
2f4c9b59
...
@@ -77,7 +77,8 @@ def _get_param(params, key, required=False):
...
@@ -77,7 +77,8 @@ def _get_param(params, key, required=False):
class
WebService
(
object
):
class
WebService
(
object
):
def
__init__
(
self
,
factory
=
None
,
version
=
None
,
metadata
=
None
,
def
__init__
(
self
,
factory
=
None
,
version
=
None
,
metadata
=
None
,
usage_documentation
=
None
):
usage_documentation
=
None
,
error_stream
=
sys
.
stderr
):
self
.
error_stream
=
error_stream
self
.
factory
=
factory
or
EdgeFactory
()
self
.
factory
=
factory
or
EdgeFactory
()
self
.
metadata
=
metadata
or
ObservatoryMetadata
().
metadata
self
.
metadata
=
metadata
or
ObservatoryMetadata
().
metadata
self
.
version
=
version
self
.
version
=
version
...
@@ -110,8 +111,9 @@ class WebService(object):
...
@@ -110,8 +111,9 @@ class WebService(object):
if
isinstance
(
timeseries_string
,
str
):
if
isinstance
(
timeseries_string
,
str
):
timeseries_string
=
timeseries_string
.
encode
(
'
utf8
'
)
timeseries_string
=
timeseries_string
.
encode
(
'
utf8
'
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
"
Error processing request: %s
"
%
str
(
e
),
if
self
.
error_stream
:
file
=
sys
.
stderr
)
print
(
"
Error processing request: %s
"
%
str
(
e
),
file
=
self
.
error_stream
)
message
=
"
Server error.
"
message
=
"
Server error.
"
error_body
=
self
.
error
(
500
,
message
,
environ
,
start_response
)
error_body
=
self
.
error
(
500
,
message
,
environ
,
start_response
)
return
[
error_body
]
return
[
error_body
]
...
...
This diff is collapsed.
Click to expand it.
test/WebService_test.py
+
1
−
1
View file @
2f4c9b59
...
@@ -138,7 +138,7 @@ def test_requests():
...
@@ -138,7 +138,7 @@ def test_requests():
assert_equals
(
response
.
status
,
'
200 OK
'
)
assert_equals
(
response
.
status
,
'
200 OK
'
)
assert_equals
(
response
.
content_type
,
'
text/plain
'
)
assert_equals
(
response
.
content_type
,
'
text/plain
'
)
# Test internal server error (use fake factory)
# Test internal server error (use fake factory)
app
=
TestApp
(
WebService
(
ErrorFactory
()))
app
=
TestApp
(
WebService
(
ErrorFactory
()
,
error_stream
=
None
))
response
=
app
.
get
(
'
/?id=BOU
'
,
expect_errors
=
True
)
response
=
app
.
get
(
'
/?id=BOU
'
,
expect_errors
=
True
)
assert_equals
(
response
.
status_int
,
500
)
assert_equals
(
response
.
status_int
,
500
)
assert_equals
(
response
.
status
,
'
500 Internal Server Error
'
)
assert_equals
(
response
.
status
,
'
500 Internal Server Error
'
)
...
...
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