Skip to content

Commit 57d98c9

Browse files
ghyatzojuliohm
andauthored
Slightly better logging experience. (#61)
* Adds a slightly better logging experience. * fix: remove last set of points before download info * fix: remove gimmick progress bar, expand Dates compat version. * Improve info message and code formatting * Improve info message --------- Co-authored-by: Júlio Hoffimann <[email protected]>
1 parent c07acc5 commit 57d98c9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ authors = ["Micky Yun Chan <[email protected]> and contributors"]
44
version = "2.0.3"
55

66
[deps]
7+
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
78
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
89
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
910

1011
[compat]
12+
Dates = "1.11"
1113
HTTP = "1"
1214
JSON = "0.21"
1315
julia = "1"

src/CDSAPI.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module CDSAPI
22

33
using HTTP
44
using JSON
5+
using Dates
56

67
"""
78
retrieve(name, params, filename; wait=1.0)
@@ -52,12 +53,17 @@ function retrieve(name, params::AbstractDict, filename; wait=1.0)
5253
data = JSON.parse(String(response.body))
5354
endpoint = Dict(response.headers)["location"]
5455

56+
laststatus = nothing
5557
while data["status"] != "successful"
5658
data = HTTP.request("GET", endpoint,
5759
["PRIVATE-TOKEN" => creds["key"]]
5860
)
5961
data = JSON.parse(String(data.body))
60-
@info "CDS request" dataset=name status=data["status"]
62+
63+
if data["status"] != laststatus
64+
@info "CDS request update on $(now())" dataset = name status = data["status"]
65+
laststatus = data["status"]
66+
end
6167

6268
if data["status"] == "failed"
6369
throw(ErrorException("""
@@ -78,6 +84,7 @@ function retrieve(name, params::AbstractDict, filename; wait=1.0)
7884
["PRIVATE-TOKEN" => creds["key"]]
7985
)
8086
body = JSON.parse(String(response.body))
87+
8188
HTTP.download(body["asset"]["value"]["href"], filename)
8289

8390
return data

0 commit comments

Comments
 (0)