Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gts2
gts2_client
Commits
16b80c1f
Commit
16b80c1f
authored
Jul 02, 2020
by
Niklas Keck
Browse files
added 'timeout' argument
parent
c08f4096
Pipeline
#9884
failed with stages
in 27 minutes and 49 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gts2_client/gts2_client.py
View file @
16b80c1f
...
...
@@ -81,7 +81,7 @@ class Gts2Request(dict):
logger
.
info
(
">>>>>> API-call: %s "
%
self
.
api_call
)
# get data, update dict from json
result
=
requests
.
get
(
self
.
api_call
,
verify
=
False
,
auth
=
opts
[
"auth"
][
"auth"
])
result
=
requests
.
get
(
self
.
api_call
,
verify
=
False
,
auth
=
opts
[
"auth"
][
"auth"
]
,
timeout
=
opts
[
"timeout"
]
)
status
=
{
"http_code"
:
result
.
status_code
}
self
.
update
(
result
.
json
())
...
...
@@ -714,7 +714,7 @@ def __get_auth(logger=None):
def
client
(
outpath
=
""
,
out_prefix
=
""
,
out_mode
=
"json"
,
geo_ll
=
(),
geo_ur
=
(),
sensor
=
"S2A"
,
bands
=
""
,
max_cloudy
=
"0.5"
,
level
=
"L2A"
,
start_date
=
""
,
end_date
=
""
,
version
=
"0.13"
,
suffix
=
""
,
minimum_fill
=
""
,
only_tile
=
""
,
stack_resolution
=
"10"
,
quiet
=
False
,
rgb_extension
=
"jpg"
,
rgb_bands_selection
=
"realistic"
,
merge_tifs
=
False
,
merge_tile
=
None
,
onlytime
=
False
):
merge_tifs
=
False
,
merge_tile
=
None
,
onlytime
=
False
,
timeout
=
None
):
"""
Downloads data via API and saves it in a wanted file format (.json, .tiff or .nc) or alternatively returns a python
dictionary.
...
...
@@ -789,7 +789,7 @@ def client(outpath="", out_prefix="", out_mode="json", geo_ll=(), geo_ur=(), sen
opts
=
{
"ll"
:
geo_ll
,
"ur"
:
geo_ur
,
"sensor"
:
sensor
,
"bands"
:
bands
,
"max_cloudy"
:
max_cloudy
,
"auth"
:
auth
,
"level"
:
level
,
"date_from"
:
start_date
,
"date_to"
:
end_date
,
"version"
:
version
,
"suffix"
:
suffix
,
"minimum_fill"
:
minimum_fill
,
"utm_zone"
:
only_tile
,
"logger"
:
logger
,
"onlytime"
:
onlytime
}
"onlytime"
:
onlytime
,
"timeout"
:
timeout
}
# actual API request
logger
.
info
(
"Requesting data from the GTS2 server ..."
,
)
...
...
@@ -919,6 +919,8 @@ if __name__ == "__main__":
help
=
"Choose MGRS tile into which the merge of files is performed (e.g. 33UUV)."
)
parser
.
add_argument
(
"-p"
,
"--onlytime"
,
action
=
"store"
,
required
=
False
,
type
=
str2bool
,
default
=
False
,
help
=
"get the available timestamps for a specific request without downloading any rasterdata"
)
parser
.
add_argument
(
"-t"
,
"--timeout"
,
action
=
"store"
,
required
=
False
,
type
=
int
,
default
=
None
,
help
=
"time to wait for a response from gts2 before raising a Timeout exception"
)
args
=
parser
.
parse_args
()
...
...
@@ -944,4 +946,5 @@ if __name__ == "__main__":
rgb_bands_selection
=
args
.
rgb_bands_selection
,
merge_tifs
=
args
.
merge_tifs
,
merge_tile
=
args
.
merge_tile
,
onlytime
=
args
.
onlytime
)
onlytime
=
args
.
onlytime
,
timeout
=
args
.
timeout
)
Niklas Keck
@niklas.keck_at_agroscience.rlp.de
mentioned in commit
4d534632
·
Jul 17, 2020
mentioned in commit
4d534632
mentioned in commit 4d534632f06e2eb374a2a21b96be874ff0445505
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment