Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tsm-orchestration
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
UFZ TSM
tsm-orchestration
Commits
a770fa2e
Commit
a770fa2e
authored
2 months ago
by
Florian Gransee
Browse files
Options
Downloads
Patches
Plain Diff
make use of raise_for_status
parent
8a3bd539
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!238
424 add uba api script
Pipeline
#486448
passed
2 months ago
Stage: integration
Stage: end-to-end
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cron/scripts/ext_api_sync/uba_api_sync.py
+26
-24
26 additions, 24 deletions
cron/scripts/ext_api_sync/uba_api_sync.py
with
26 additions
and
24 deletions
cron/scripts/ext_api_sync/uba_api_sync.py
+
26
−
24
View file @
a770fa2e
...
...
@@ -53,21 +53,22 @@ def get_components_and_scopes():
response_components
=
requests
.
get
(
"
https://www.umweltbundesamt.de/api/air_data/v3/components/json
"
)
response_components
.
raise_for_status
()
response_scopes
=
requests
.
get
(
"
https://www.umweltbundesamt.de/api/air_data/v3/scopes/json
"
)
if
response_co
mponents
.
status_code
==
200
and
response_scopes
.
status_code
==
200
:
components
=
{
int
(
v
[
0
]):
v
[
1
]
for
k
,
v
in
response_components
.
json
().
items
()
if
k
not
in
[
"
count
"
,
"
indices
"
]
}
scopes
=
{
int
(
v
[
0
]):
v
[
1
]
for
k
,
v
in
response_scopes
.
json
().
items
()
if
k
not
in
[
"
count
"
,
"
indices
"
]
}
return
components
,
scopes
response_
s
co
pes
.
raise_for_status
()
components
=
{
int
(
v
[
0
]):
v
[
1
]
for
k
,
v
in
response_components
.
json
().
items
()
if
k
not
in
[
"
count
"
,
"
indices
"
]
}
scopes
=
{
int
(
v
[
0
]):
v
[
1
]
for
k
,
v
in
response_scopes
.
json
().
items
()
if
k
not
in
[
"
count
"
,
"
indices
"
]
}
return
components
,
scopes
def
get_station_info
(
station_id
:
str
)
->
list
:
...
...
@@ -78,12 +79,12 @@ def get_station_info(station_id: str) -> list:
response
=
requests
.
get
(
"
https://www.umweltbundesamt.de/api/air_data/v3/measures/limits
"
)
if
response
.
status_code
==
200
:
response_json
=
response
.
json
()[
"
data
"
]
for
k
,
v
in
response_json
.
items
():
if
v
[
2
]
==
station_id
:
station_info
.
append
({
"
scope
"
:
int
(
v
[
0
]),
"
component
"
:
int
(
v
[
1
])})
return
station_info
response
.
raise_for_status
()
response_json
=
response
.
json
()[
"
data
"
]
for
k
,
v
in
response_json
.
items
():
if
v
[
2
]
==
station_id
:
station_info
.
append
({
"
scope
"
:
int
(
v
[
0
]),
"
component
"
:
int
(
v
[
1
])})
return
station_info
def
request_measure_endpoint
(
...
...
@@ -111,12 +112,12 @@ def request_measure_endpoint(
url
=
"
https://www.umweltbundesamt.de/api/air_data/v3/measures/json
"
,
params
=
params
,
)
if
response
.
status_code
==
200
:
response_json
=
response
.
json
()
if
response_json
[
"
data
"
]:
return
response_json
[
"
data
"
][
station_id
]
else
:
return
response_json
[
"
data
"
]
response
.
raise_for_status
()
response_json
=
response
.
json
()
if
response_json
[
"
data
"
]:
return
response_json
[
"
data
"
][
station_id
]
else
:
return
response_json
[
"
data
"
]
def
combine_measure_responses
(
...
...
@@ -199,6 +200,7 @@ def get_airquality_data(
response
=
requests
.
get
(
"
https://www.umweltbundesamt.de/api/air_data/v3/airquality/json
"
,
params
=
params
)
response
.
raise_for_status
()
response_data
=
response
.
json
()[
"
data
"
][
station_id
]
aqi_data
=
list
()
for
k
,
v
in
response_data
.
items
():
...
...
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