441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
|
}
return https://urn.to/r/pkg; # NOTE: System default.
}
#
# NOTE: This procedure returns the full URI to use when looking up a
# specific package via the package repository server. The apiKey
# argument is the API key to use -OR- an empty string if a public
# package is being looked up. The package argument is the name
# of the package being looked up, it cannot be an empty string.
# The version argument is the specific version being looked up
# -OR- an empty string for any available version. No HTTP request
# is issued by this procedure; it just returns the URI to use.
#
proc getLookupUri { apiKey package version } {
set baseUri [getLookupBaseUri]
if {[string length $baseUri] == 0} then {
return ""
}
#
# NOTE: Build the HTTP request URI using the specified query parameter
# values, escaping them as necessary. Also, include the standard
# query parameters with constant values for this request type.
#
if {[isEagle]} then {
return [appendArgs \
$baseUri ?raw=1&method=lookup&apiKey= [uri escape uri $apiKey] \
&package= [uri escape uri $package] &version= [uri escape uri \
$version]]
} else {
package require http 2.0
return [appendArgs \
$baseUri ? [::http::formatQuery raw 1 method lookup \
apiKey $apiKey package $package version $version]]
}
}
#
# NOTE: This procedure returns the version of the package that should be
# used to lookup the associated [package ifneeded] script -OR- an
# empty string if no such version exists. The package argument is
|
|
|
|
|
|
|
|
>
|
>
>
>
|
>
>
>
>
>
|
|
|
>
>
|
|
>
>
>
>
>
|
>
>
|
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
|
}
return https://urn.to/r/pkg; # NOTE: System default.
}
#
# NOTE: This procedure returns the full URI to use when looking up a
# specific package via the package repository server. The apiKeys
# argument is the list of API keys to use -OR- an empty list if a
# public package is being looked up. The package argument is the
# name of the package being looked up, it cannot be an empty
# string. The version argument is the specific version being
# looked up -OR- an empty string for any available version. There
# are no HTTP requests issued by this procedure; it simply returns
# the URI to use.
#
proc getLookupUri { apiKeys package version } {
set baseUri [getLookupBaseUri]
if {[string length $baseUri] == 0} then {
return ""
}
#
# NOTE: Build the HTTP request URI using the specified query parameter
# values, escaping them as necessary. Also, include the standard
# query parameters with constant values for this request type.
#
set anonymousApiKey ""
if {[isEagle]} then {
if {[llength $apiKeys] > 0} then {
return [appendArgs \
$baseUri ?raw=1&method=lookup&apiKeys= [uri escape uri \
[join $apiKeys ,]] &package= [uri escape uri $package] \
&version= [uri escape uri $version]]
} else {
return [appendArgs \
$baseUri ?raw=1&method=lookup&apiKey= [uri escape uri \
$anonymousApiKey] &package= [uri escape uri $package] \
&version= [uri escape uri $version]]
}
} else {
package require http 2.0
if {[llength $apiKeys] > 0} then {
return [appendArgs \
$baseUri ? [::http::formatQuery raw 1 method lookup \
apiKeys [join $apiKeys ,] package $package version \
$version]]
} else {
return [appendArgs \
$baseUri ? [::http::formatQuery raw 1 method lookup \
apiKey $anonymousApiKey package $package version \
$version]]
}
}
}
#
# NOTE: This procedure returns the version of the package that should be
# used to lookup the associated [package ifneeded] script -OR- an
# empty string if no such version exists. The package argument is
|
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
|
return $result
}
#
# NOTE: This procedure issues an HTTP request that should return metadata
# that can be used to load and/or provide the specified package.
# The apiKey argument is the API key to use -OR- an empty string if
# a public package is being looked up. The package argument is the
# name of the package, it cannot be an empty string. The version
# argument is the specific version being looked up -OR- an empty
# string for any available version. This procedure may raise script
# errors. All line-endings are normalized to Unix-style; therefore,
# all script signatures must assume this.
#
proc getLookupData { apiKey package version } {
variable verboseUriDownload
set uri [getLookupUri $apiKey $package $version]
if {[string length $uri] == 0} then {
return ""
}
if {$verboseUriDownload} then {
pkgLog [appendArgs \
|
|
|
|
|
|
|
|
|
|
|
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
|
return $result
}
#
# NOTE: This procedure issues an HTTP request that should return metadata
# that can be used to load and/or provide the specified package.
# The apiKeys argument is the list of API keys to use -OR- an empty
# list if a public package is being looked up. The package argument
# is the name of the package, it cannot be an empty string. The
# version argument is the specific version being looked up -OR- an
# empty string for any available version. This procedure may raise
# script errors. All line-endings are normalized to Unix-style;
# therefore, all script signatures must assume this.
#
proc getLookupData { apiKeys package version } {
variable verboseUriDownload
set uri [getLookupUri $apiKeys $package $version]
if {[string length $uri] == 0} then {
return ""
}
if {$verboseUriDownload} then {
pkgLog [appendArgs \
|
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
|
#
# <public>
proc getPackageFromRepository { package version caller } {
#
# NOTE: Get the list of API keys and try each one, in order, until
# the package is found.
#
set apiKeys [getApiKeys]; lappend apiKeys ""
foreach apiKey $apiKeys {
#
# NOTE: Issue the lookup request to the remote package repository.
#
set data [getLookupData $apiKey $package $version]
#
# NOTE: Attempt to grab the lookup code from the response data.
#
set code [getLookupCodeFromData $data]
#
# NOTE: Did the lookup operation succeed? If so, stop trying
# other API keys.
#
if {[isLookupCodeOk $code]} then {
break
}
}
#
# NOTE: Attempt to grab the lookup data from the response data.
# Upon failure, this should contain the error message.
#
set result [getLookupResultFromData $data]
|
|
<
|
|
>
|
|
|
|
>
|
|
|
|
<
|
|
>
>
|
>
>
|
>
>
>
>
>
|
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
|
#
# <public>
proc getPackageFromRepository { package version caller } {
#
# NOTE: Get the list of API keys and try each one, in order, until
# the package is found.
#
set apiKeys [getApiKeys]
#
# NOTE: Issue the non-anonymous lookup request to the remote
# package repository.
#
set data [getLookupData $apiKeys $package $version]
#
# NOTE: Attempt to grab the lookup code from the non-anonymous
# response data.
#
set code [getLookupCodeFromData $data]
#
# NOTE: If necessary, fallback with to an anonymous request.
#
if {![isLookupCodeOk $code]} then {
#
# NOTE: Issue the anonymous lookup request to the remote
# package repository.
#
set data [getLookupData [list] $package $version]
#
# NOTE: Attempt to grab the lookup code from the anonymous
# response data.
#
set code [getLookupCodeFromData $data]
}
#
# NOTE: Attempt to grab the lookup data from the response data.
# Upon failure, this should contain the error message.
#
set result [getLookupResultFromData $data]
|