-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating sloshdsp.kit and setup.tcl to work with PUBLIC assets.
- Loading branch information
1 parent
32ab861
commit 5abf520
Showing
3 changed files
with
11 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!./bin/tclkitsh854.exe | ||
#------------------------------------------------------------------------------- | ||
# setup.tcl Last Change: 2024-04-25 | ||
# setup.tcl Last Change: 2024-04-29 | ||
# [email protected] | ||
# NWS/OSTI/MDL/DSD | ||
#------------------------------------------------------------------------------- | ||
|
@@ -9,38 +9,20 @@ proc Usage {} { | |
set base [file tail $argv0] | ||
puts "Download and install assets (dd3.kit, shpfiles.tar.gz) from GitHub" | ||
puts "" | ||
puts "Usage: $base <cmd> <method>, where:" | ||
puts "Usage: $base <cmd>, where:" | ||
puts " <cmd> is:" | ||
puts " help = Display this message and exit" | ||
puts " all = Download basin, storm, and GUI data" | ||
puts " <method> is:" | ||
puts " manual = Use tarballs in ./tar" | ||
puts " PAT(=<file>) = Use GitHub Personal Access Token (PAT) in <file>" | ||
puts " if (=<file>) is omitted use ~/.gitHub_pat" | ||
puts "" | ||
puts "Example:" | ||
puts " 1) ./$base all PAT" | ||
puts " Use PAT (~/.gitHub_pat) to install all assests" | ||
puts " 1) ./$base all" | ||
puts " Install all assests" | ||
} | ||
if {($argc != 2) || ([lindex $argv 0] == "help")} { Usage ; exit 0 } | ||
if {($argc != 1) || ([lindex $argv 0] == "help")} { Usage ; exit 0 } | ||
|
||
set Cmd [lindex $argv 0] | ||
if {$Cmd != "all"} { Usage ; exit 0 } | ||
|
||
set Method [lindex $argv 1] | ||
if {$Method == "manual"} { set TOKEN "manual" | ||
} elseif {[string range $Method 0 2] == "PAT"} { | ||
set PAT_FILE [string range $Method 4 end] | ||
if {[string length $PAT_FILE] == 0} { | ||
set PAT_FILE $env(HOME)/.gitHub_pat | ||
} | ||
set fp [open $PAT_FILE r] | ||
gets $fp TOKEN | ||
close $fp | ||
} else { | ||
Usage ; exit 0 | ||
} | ||
|
||
#------------------------------------------------------------------------------- | ||
# @brief One line JSON parser | ||
# | ||
|
@@ -64,7 +46,7 @@ proc json2dict JSONtext { | |
#------------------------------------------------------------------------------- | ||
# @brief Download a file (asset) from GitHub | ||
# | ||
# @param Token: Private Access Token for private repositories | ||
# @param curl: Program to use for 'Curl' | ||
# @param url: URL for the GitHub repo releases | ||
# @param Ver: Name of release that this is an asset of | ||
# @param Name: Name of asset. | ||
|
@@ -73,13 +55,12 @@ proc json2dict JSONtext { | |
# @author [email protected] (NWS/OSTI/MDL/DSD) | ||
# @date Mar 2023: AAT - Created | ||
#------------------------------------------------------------------------------- | ||
proc getGitHubAsset {curl Token url Ver Name dstName} { | ||
proc getGitHubAsset {curl url Ver Name dstName} { | ||
# This call to curl could be done in Tcl via: | ||
# geturl https://$url -binary true \ | ||
# -progress ::http::Progress -blocksize $chunk \ | ||
# -headers [list "Authorization" "token $Token" "Accept" "application/vnd.github.v3.raw"] | ||
catch {exec $curl -s -L \ | ||
-H "Authorization: Bearer $Token" \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://$url} ans | ||
|
@@ -101,10 +82,9 @@ proc getGitHubAsset {curl Token url Ver Name dstName} { | |
file delete $Name | ||
} | ||
catch {exec $curl -s -L \ | ||
-H "Authorization: Bearer $Token" \ | ||
-H "Accept: application/octet-stream" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://$Token:@$url/assets/$ID > $dstName} ans | ||
https://$url/assets/$ID > $dstName} ans | ||
return 0 | ||
} | ||
|
||
|
@@ -115,11 +95,10 @@ set UNZIP $srcDir/bin/unzip.exe | |
set BASE "api.github.com/repos" | ||
|
||
puts "Getting dd3.kit" | ||
getGitHubAsset $CURL $TOKEN $BASE/ArthurTaylorNWS/sdp/releases Assets \ | ||
dd3.kit dd3.kit | ||
getGitHubAsset $CURL $BASE/NOAA-MDL/sdp/releases Assets dd3.kit dd3.kit | ||
|
||
puts "Getting shpfiles.zip" | ||
getGitHubAsset $CURL $TOKEN $BASE/ArthurTaylorNWS/sdp/releases Assets \ | ||
getGitHubAsset $CURL $BASE/NOAA-MDL/sdp/releases Assets \ | ||
shpfiles.zip shpfiles.zip | ||
|
||
# Unpack the shpfiles.zip file | ||
|
Binary file not shown.