Ignore:
Timestamp:
Jun 22, 2011, 8:49:33 PM (6 years ago)
Author:
derek@…
Message:
  • Use stats_url and stats_id from macports.conf
  • Submit stats_id along with other data
  • Added checks for existence of those two variables before using them
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-statistics/base/src/port/port.tcl

    r79522 r79663  
    25892589            set entry "\"$name\":\"$port($name)\""
    25902590            set json "$json$entry"
    2591 
    2592 
    25932591        }
    25942592
     
    26272625    # Top level container for os and port data
    26282626    # Returns a JSON Object with three 
    2629     proc json_encode_stats {os_dict ports_dict} {
     2627    proc json_encode_stats {id os_dict ports_dict} {
    26302628        upvar 1 $os_dict os
    26312629        upvar 1 $ports_dict ports
     
    26362634
    26372635        set json "\{"
     2636        set json "$json \"id\":\"$id\","
    26382637        set json "$json \"os\":$os_json,"
    26392638        set json "$json \"active_ports\":$active_ports_json,"
     
    26442643    }
    26452644
     2645
    26462646    switch $cmd {
    26472647        "submit" {
    2648             # TODO: Get URL from a configuration variable
    2649             set url "http://127.0.0.1/cgi-bin/data.py"
    2650             set json [json_encode_stats os ports]
    2651             curl post "data=$json" $url     
     2648            if {![info exists macports::stats_url]} {
     2649                ui_error "Configuration variable stats_url is not set"
     2650                return 0
     2651            }
     2652            if {![info exists macports::stats_id]} {
     2653                ui_error "Configuration variable stats_id is not set"
     2654                return 0
     2655            }
     2656           
     2657            set json [json_encode_stats ${macports::stats_id} os ports]
     2658            curl post "data=$json" ${macports::stats_url} 
    26522659        }
    26532660        default {
Note: See TracChangeset for help on using the changeset viewer.