tcl-hacks

Check-in [9c29f30147]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:more consistent error handling. Display TPM throws nicely, let others go through to the keeper
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9c29f301472f2ebc1a848bb90a7bf9d45885c951
User & Date: aspect 2018-07-24 11:24:31
Context
2018-07-24
13:12
follow dependencies in install! check-in: 3efe5804f5 user: aspect tags: trunk
11:24
more consistent error handling. Display TPM throws nicely, let others go through to the keeper check-in: 9c29f30147 user: aspect tags: trunk
11:17
purge remnants of map_os/map_cpu check-in: d3282bd58d user: aspect tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to hacks/cuppa/tpc.tcl.

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
...
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
...
548
549
550
551
552
553
554



555
556
557
558
559
560
561
...
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
    tailcall trace add variable :#finally#: unset [list apply [list args $args]]
}

proc dictargs {defaults} {
    upvar 1 args args
    set keys [dict keys $defaults]
    if {[catch {dict size $args}]} {
        tailcall tailcall throw {TCL BAD_ARGS} "Expected dictionary argument with keys in [list $keys]"
    }
    dict for {k v} $args {
        if {$k ni $keys} {
            tailcall tailcall throw {TCL WRONG_ARGS} "Incorrect dictionary argument \"$k\", must be one of [list $keys]"
        }
    }
    set args [dict merge $defaults $args]
    tailcall dict with args {}
}

proc createfile {path data args} {
................................................................................
            set meta [$zip contents teapot.txt]
            log "Found metadata in zip teapot.txt"
        }
        $zip destroy
    }
    # FIXME: should check first line for eg {Package name version}
    if {$meta eq ""} {
        throw {TPC NO_META} "Metadata not found!"
    }
    set meta [regexp -line -inline -all {^(?:\s*#)?\s*Meta (\S+)\s+(.*)} $meta]
    foreach {_ key val} $meta {
        dict lappend res $key {*}$val
    }
    return -type dict $res
}
................................................................................
    }
    lappend res
    return -type dicts $res
}

proc mkenv {dir} {
    if {[file isdirectory $dir]} {
        throw {TPC EXISTS} "Directory \"$dir\" already exists!"
    }

    set tclexe [info nameofexe]
    set tclver [info patch]
    regexp {^(\d+).(\d+)} $tclver -> majver minver

    log "Creating Tcl environment in $dir for $tclexe ($tclver)"
................................................................................
    finally close $fd

    # FIXME: read params from this file
    seek $fd 0 end

    # FIXME: follow dependencies
    set _ [get $name {*}$args]



    dict with _ {}

    switch $type {
        "application" {
            createfile [set loc $dir/bin/$name] $data -permissions 0755
        }
        "package" {
................................................................................
        init_db
        index:add http://teapot.rkeene.org/
        index:add http://teapot.activestate.com/
    }

    try {
        set r [{*}$args]
    } on error {err opt} {
        log "Error: $err"
        array set E $opt
        parray E
        return 1
    } on ok {res opt} {
        if {![dict exists $opt -type]} {
            dict set opt -type text
        }
        switch [dict get $opt -type] {
            ignore {}







|



|







 







|







 







|







 







>
>
>







 







|

<
<







39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
...
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
...
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
...
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
...
607
608
609
610
611
612
613
614
615


616
617
618
619
620
621
622
    tailcall trace add variable :#finally#: unset [list apply [list args $args]]
}

proc dictargs {defaults} {
    upvar 1 args args
    set keys [dict keys $defaults]
    if {[catch {dict size $args}]} {
        tailcall tailcall throw {TPM BAD_ARGS} "Expected dictionary argument with keys in [list $keys]"
    }
    dict for {k v} $args {
        if {$k ni $keys} {
            tailcall tailcall throw {TPM WRONG_ARGS} "Incorrect dictionary argument \"$k\", must be one of [list $keys]"
        }
    }
    set args [dict merge $defaults $args]
    tailcall dict with args {}
}

proc createfile {path data args} {
................................................................................
            set meta [$zip contents teapot.txt]
            log "Found metadata in zip teapot.txt"
        }
        $zip destroy
    }
    # FIXME: should check first line for eg {Package name version}
    if {$meta eq ""} {
        throw {TPM NO_META} "Metadata not found!"
    }
    set meta [regexp -line -inline -all {^(?:\s*#)?\s*Meta (\S+)\s+(.*)} $meta]
    foreach {_ key val} $meta {
        dict lappend res $key {*}$val
    }
    return -type dict $res
}
................................................................................
    }
    lappend res
    return -type dicts $res
}

proc mkenv {dir} {
    if {[file isdirectory $dir]} {
        throw {TPM EXISTS} "Directory \"$dir\" already exists!"
    }

    set tclexe [info nameofexe]
    set tclver [info patch]
    regexp {^(\d+).(\d+)} $tclver -> majver minver

    log "Creating Tcl environment in $dir for $tclexe ($tclver)"
................................................................................
    finally close $fd

    # FIXME: read params from this file
    seek $fd 0 end

    # FIXME: follow dependencies
    set _ [get $name {*}$args]
    if {$_ eq ""} {
        throw {TPM NOT_FOUND} "No package found matching $name $args"
    }
    dict with _ {}

    switch $type {
        "application" {
            createfile [set loc $dir/bin/$name] $data -permissions 0755
        }
        "package" {
................................................................................
        init_db
        index:add http://teapot.rkeene.org/
        index:add http://teapot.activestate.com/
    }

    try {
        set r [{*}$args]
    } trap {TPM} {err opt} {
        log "Error: $err"


        return 1
    } on ok {res opt} {
        if {![dict exists $opt -type]} {
            dict set opt -type text
        }
        switch [dict get $opt -type] {
            ignore {}