[79663] branches/gsoc11-statistics/base/src/port/port.tcl

derek at macports.org derek at macports.org
Wed Jun 22 13:49:33 PDT 2011


Revision: 79663
          http://trac.macports.org/changeset/79663
Author:   derek at macports.org
Date:     2011-06-22 13:49:33 -0700 (Wed, 22 Jun 2011)
Log 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

Modified Paths:
--------------
    branches/gsoc11-statistics/base/src/port/port.tcl

Modified: branches/gsoc11-statistics/base/src/port/port.tcl
===================================================================
--- branches/gsoc11-statistics/base/src/port/port.tcl	2011-06-22 20:47:54 UTC (rev 79662)
+++ branches/gsoc11-statistics/base/src/port/port.tcl	2011-06-22 20:49:33 UTC (rev 79663)
@@ -2588,8 +2588,6 @@
             # Format the entry as "name_string":"value"
             set entry "\"$name\":\"$port($name)\"" 
             set json "$json$entry"
-
-
         }
 
         set json "$json\}"
@@ -2626,7 +2624,7 @@
 
     # Top level container for os and port data
     # Returns a JSON Object with three  
-    proc json_encode_stats {os_dict ports_dict} {
+    proc json_encode_stats {id os_dict ports_dict} {
         upvar 1 $os_dict os
         upvar 1 $ports_dict ports
 
@@ -2635,6 +2633,7 @@
         set inactive_ports_json [json_encode_portlist [dict get $ports "inactive"]]
 
         set json "\{"
+        set json "$json \"id\":\"$id\","
         set json "$json \"os\":$os_json,"
         set json "$json \"active_ports\":$active_ports_json,"
         set json "$json \"inactive_ports\":$inactive_ports_json"
@@ -2643,12 +2642,20 @@
         return $json
     }
 
+
     switch $cmd {
         "submit" {
-            # TODO: Get URL from a configuration variable
-            set url "http://127.0.0.1/cgi-bin/data.py"
-            set json [json_encode_stats os ports]
-            curl post "data=$json" $url      
+            if {![info exists macports::stats_url]} {
+                ui_error "Configuration variable stats_url is not set"
+                return 0
+            }
+            if {![info exists macports::stats_id]} {
+                ui_error "Configuration variable stats_id is not set"
+                return 0
+            }
+            
+            set json [json_encode_stats ${macports::stats_id} os ports]
+            curl post "data=$json" ${macports::stats_url}  
         }
         default {
             puts "Unknown subcommand. See port help stats"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110622/cec59fff/attachment.html>


More information about the macports-changes mailing list