Check-in [7a658563b4]
Not logged in
Overview
Comment:Completely refactor the 'package unknown' handler error handling.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7a658563b409a52f167b519d34185e3110171b7a
User & Date: mistachkin on 2016-08-17 05:27:03
Other Links: manifest | tags
Context
2016-08-17
06:18
Do not try to auto-hook the 'package unknown' handler if it is already hooked. check-in: e7c21e360a user: mistachkin tags: trunk
05:27
Completely refactor the 'package unknown' handler error handling. check-in: 7a658563b4 user: mistachkin tags: trunk
02:27
Adjust comments. check-in: 607e185516 user: mistachkin tags: trunk
Changes

Modified client/pkgr.eagle from [c24c2305f9] to [a9e801c84e].

24
25
26
27
28
29
30




























31
32
33
34
35
36
37
  # NOTE: This package absolutely requires the Eagle core script library
  #       package, even when it is being used by native Tcl.  If needed,
  #       prior to loading this package, the native Tcl auto-path should
  #       be modified to include the "Eagle1.0" directory (i.e. the one
  #       containing the Eagle core script library file "init.eagle").
  #
  package require Eagle.Library





























  proc stringIsList { value } {
    if {[isEagle]} then {
      return [string is list $value]
    } else {
      global tcl_version








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  # NOTE: This package absolutely requires the Eagle core script library
  #       package, even when it is being used by native Tcl.  If needed,
  #       prior to loading this package, the native Tcl auto-path should
  #       be modified to include the "Eagle1.0" directory (i.e. the one
  #       containing the Eagle core script library file "init.eagle").
  #
  package require Eagle.Library

  proc formatPackageName { package version } {
    return [string trim [appendArgs \
        $package " " [getLookupVersion $version]]]
  }

  proc formatResult { code result } {
    switch -exact -- $code {
      0 {set codeString ok}
      1 {set codeString error}
      2 {set codeString return}
      3 {set codeString break}
      4 {set codeString continue}
      default {set codeString [appendArgs unknown( $code )]}
    }

    if {[string length $result] > 0} then {
      return [appendArgs $codeString ": " [list $result]]
    } else {
      return $codeString
    }
  }

  proc pkgLog { string } {
    catch {
      tclLog [appendArgs [pid] " : " [clock seconds] " : pkgr : " $string]
    }
  }

  proc stringIsList { value } {
    if {[isEagle]} then {
      return [string is list $value]
    } else {
      global tcl_version

759
760
761
762
763
764
765


766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797




798
799
800

801
802


803
804
805
806

807
808


809
810
811
812
813
814
815

816
817
818
819
820
821
822
823

824
825
826
827
828
829
830
831
832

833
834
835
836
837
838
839

  #
  # NOTE: This version argument to this procedure must be optional, because
  #       Eagle does not add a version argument when one is not supplied to
  #       the [package require] sub-command itself.
  #
  proc packageUnknownHandler { package {version ""} } {


    #
    # NOTE: First, run our [package unknown] handler.
    #
    if {[catch {main $package $version handler} error(1)] == 0} then {
      #
      # NOTE: The repository [package unknown] handler succeeded, run the
      #       saved [package unknown] handler.
      #
      if {[catch {
        runSavedPackageUnknownHandler $package $version
      } error(2)] == 0} then {
        #
        # NOTE: Success?  Just return and let Tcl (or Eagle) handle the
        #       rest.  This is the "happy" path.
        #
        return
      } else {
        #
        # NOTE: Failure?  Attempt to log the error message.
        #
        catch {
          tclLog [appendArgs \
              "pkgr: saved handler failed for \"" [appendArgs [string \
              trim $package " " $version]] "\", error: " $error(2)]
        }
      }
    } else {
      #
      # NOTE: Failure?  Attempt to log the error message and then maybe
      #       try the original [package unknown] handler.
      #
      catch {




        tclLog [appendArgs \
            "pkgr: new handler failed for \"" [appendArgs [string \
            trim $package " " $version]] "\", error: " $error(1)]

      }



      #
      # NOTE: The repository [package unknown] handler failed, run the
      #       saved [package unknown] handler anyway.  There is almost
      #       no chance of this actually providing the package.

      #
      if {[catch {


        runSavedPackageUnknownHandler $package $version
      } error(2)] == 0} then {
        #
        # NOTE: Success?  Just return and let Tcl (or Eagle) handle the
        #       rest.
        #
        return

      } else {
        #
        # NOTE: Failure?  Attempt to log the error message.
        #
        catch {
          tclLog [appendArgs \
              "pkgr: old handler failed for \"" [appendArgs [string \
              trim $package " " $version]] "\", error: " $error(2)]

        }
      }
    }

    #
    # NOTE: Both [package unknown] handlers failed in some way, return the
    #       error messages (i.e. both of them).
    #
    error [array get error]

  }

  proc setupPackageUnknownVars {} {
    #
    # NOTE: Prevent progress messages from being displayed while downloading
    #       from the repository, etc?  By default, this is enabled.
    #







>
>



|
|
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
|
|
|
|
|
<
|
<
|
|
|
>
>
>
>
|
|
|
>
|
|
>
>
|
|
<
<
>
|
|
>
>
|
<
<
<
|
<
<
>
|
<
<
<
|
|
<
|
>
|
|
<
|
<
|
<
|
|
>







787
788
789
790
791
792
793
794
795
796
797
798
799
800





801










802
803
804
805
806

807

808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824


825
826
827
828
829
830



831


832
833



834
835

836
837
838
839

840

841

842
843
844
845
846
847
848
849
850
851

  #
  # NOTE: This version argument to this procedure must be optional, because
  #       Eagle does not add a version argument when one is not supplied to
  #       the [package require] sub-command itself.
  #
  proc packageUnknownHandler { package {version ""} } {
    variable verboseUnknownResult

    #
    # NOTE: First, run our [package unknown] handler.
    #
    set code(1) [catch {main $package $version handler} result(1)]






    if {$verboseUnknownResult} then {










      pkgLog [appendArgs \
          "repository handler results for package \"" [formatPackageName \
          $package $version] "\", are " [formatResult $code(1) $result(1)]]
    }


    #

    # NOTE: Next, run the saved [package unknown] handler.
    #
    set code(2) [catch {
      runSavedPackageUnknownHandler $package $version
    } result(2)]

    if {$verboseUnknownResult} then {
      pkgLog [appendArgs \
          "saved handler results for package \"" [formatPackageName \
          $package $version] "\" are " [formatResult $code(2) $result(2)]]
    }

    #
    # NOTE: Finally, check if the package was actually loaded and then
    #       optionally record/log the results.
    #
    set command [list package present $package]


    if {[string length $version] > 0} then {lappend command $version}

    if {[catch $command] == 0} then {
      if {$verboseUnknownResult} then {
        pkgLog [appendArgs \
            "package \"" [formatPackageName $package $version] \



            "\" was loaded."]


      }
    } else {



      if {$verboseUnknownResult} then {
        pkgLog [appendArgs \

            "package \"" [formatPackageName $package $version] \
            "\" was not loaded."]
      }


      set result(3) [appendArgs \

          "can't find package " [formatPackageName $package $version]]


      error [array get result]
    }
  }

  proc setupPackageUnknownVars {} {
    #
    # NOTE: Prevent progress messages from being displayed while downloading
    #       from the repository, etc?  By default, this is enabled.
    #
888
889
890
891
892
893
894










895
896
897
898
899
900
901
    #       when called from the [package unknown] handler?
    #
    variable strictUnknownLanguage; # DEFAULT: true

    if {![info exists strictUnknownLanguage]} then {
      set strictUnknownLanguage true
    }










  }

  proc main { package version caller } {
    #
    # NOTE: Issue the lookup request to the remote package repository.
    #
    set data [getLookupData \







>
>
>
>
>
>
>
>
>
>







900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
    #       when called from the [package unknown] handler?
    #
    variable strictUnknownLanguage; # DEFAULT: true

    if {![info exists strictUnknownLanguage]} then {
      set strictUnknownLanguage true
    }

    #
    # NOTE: Emit diagnostic messages when a [package unknown] handler
    #       is called?
    #
    variable verboseUnknownResult; # DEFAULT: false

    if {![info exists verboseUnknownResult]} then {
      set verboseUnknownResult false
    }
  }

  proc main { package version caller } {
    #
    # NOTE: Issue the lookup request to the remote package repository.
    #
    set data [getLookupData \

Modified client/pkgr.eagle.harpy from [bf0d393649] to [f7f47c423a].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED.
-->
<Certificate xmlns="https://eagle.to/2011/harpy"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Protocol>None</Protocol>
  <Vendor>Mistachkin Systems</Vendor>
  <Id>cabfad50-50cd-4e56-91b7-2a30e4703f92</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-17T02:26:59.0495625Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    ic5Xb1Ywej2L2EvXHAhuGGSVvtCLxFa347H0c9dy26lkCprMImPkU5YgPcALLwhlkyNVeshaZ/LW
    qJKahg1MeWhpgVMU2C3n5cOEAYG4I/xpgUduDMLxMUhXyIMDap/NrsFZ74ckmT3KuG6OzCTDnrvz
    nQGzexkbZyzhhwS/ZOrhZ66dcg4dDs1fwOdBDCDVfF2Wq4vDGRGgdR8e12m6Xg07Qr0r8bTxuL9K
    Yz5AZB2xJj13TVYtdfBjBvSrjnMFzKI24wLmLCVqCJDWqQYnFNT+ElGeTavvPX4oRQx6L7xQ7SEa
    CkYCIQFnv1i60aP9VcXWwNTm2YOvs3ol+UrEMQP1z0HwKpYeCyK2vnrGLmR+nrPlTkIVquPO4hIP
    w1nLkBIAJ5u8uXIqqHO7znTw7RyTAFQIMhj5sI6KVttcDymS9NSKJV0Yv1vS/mAyGfGcCmjp2mcZ
    zcWPN56tgOAs2LyYQbfU9ZOvry2hf75M17EJdjURcDDQL8Whygo36e5Rgr9WdcIJfjdPTc06oEtZ
    Rz8zlsWrC5IWhlKWBh8GNQ4aEq1Hd7glmFP3tlbV68SsynCNkolenOm2UHJuMGxThtlwJzD6rUhz
    0mUnnC5fMXnt1j/CL9H2yUU8EXz9E+uCNmUfi2SMhYoJa29/Miix32vAGEUuq6rgMdj8Hx3rbeyH
    F2zKQX1TWnjCgmskukcWrhb+do3SX1Cc9UyoaPmHCeUZtn+Yy/zK1i5Nfh4Ys4CHfDsQFucE2m/H
    qnGa7hl61od5hCGUrnnBJ/6eDCq5QC7sVYkIRquKYOPuqba6KZ3CvDzlKlM6F2VzLsBcK4wClZYE
    7vMw18hFrceQ9sA9oakZnaOPTz+pXD36iGaAmmvf7Wpq2uVduoCyDVDqI36K1vmnl0vUP1GexXUr
    nAmKejdabMQyl/hxw2YiMMs5IIAqnzwN9unQPCZ3RObMzcywGlei4VH1SwD7/m/Y7QE2zJP76XWv
    h7uTSD+xvcjMzQaeQCwJJzSU7ekVLzHicLCSr0oTKIeWy19XABy87qbbk+vqML531iM0T2JN+ivG
    o5cFnxhok7tY3iT2WMYPQ8QFFh8AXoVOZKep7iYUykgyA42CK7+6U6St6ilBJ/IBAbdpFQVQthHr
    0EsyMusyZkwmsBKlNb4nVAksSSmTPU/+3ZEcNvPQ1SXJ9XaKlqfUHa3hpAbv7j6dMLjWlrqTf9Ee
    UPRIbOq+m9eLY6V3kaLo9ddp31cdxRLfsRRtG0rS0bzgwZZ5EEHuNnHyfLngxjjUONfURasUYBil
    pUGepLpNik36lipHHMedJ+88tDjPeRkHAwwE/PLCk0HDZQ7V1qwP2BT6qCvhISh83WSA0vWkSQ==
  </Signature>
</Certificate>







|


|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED.
-->
<Certificate xmlns="https://eagle.to/2011/harpy"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Protocol>None</Protocol>
  <Vendor>Mistachkin Systems</Vendor>
  <Id>2a821830-6f0d-48e2-a69a-c6a1e4566199</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-17T05:26:13.0964375Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    oabGV6fNKxQn09gnh/ITDiU+gwi+z7nWyNnDj5TJH/A7uDJis+SA9IhA6aQ7TFLeeU1a3UV4jB3B
    aBCFABg2zNKjrX6q1T6wYYdsKRYtQgsWFQSCB+3OuTglh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