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

derek at macports.org derek at macports.org
Fri May 27 10:52:35 PDT 2011


Revision: 78936
          http://trac.macports.org/changeset/78936
Author:   derek at macports.org
Date:     2011-05-27 10:52:35 -0700 (Fri, 27 May 2011)
Log Message:
-----------
Added port stats action.

This action takes one optional argument - submit

If no argument is given then port stats displays (in human readable form) the 
information that will be submitted to MacPorts. As of now only information 
relevant to building ports is displayed.

The submit subcommand will initiate the actual upload. Right now it exists 
only as a placeholder and outputs the text "Will submit collected data"

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-05-27 15:41:09 UTC (rev 78935)
+++ branches/gsoc11-statistics/base/src/port/port.tcl	2011-05-27 17:52:35 UTC (rev 78936)
@@ -2477,7 +2477,45 @@
     return 0
 }
 
+proc action_stats { action portlist opts } {    
 
+    # If no subcommands are given (portlist is empty) print out OS information
+    if {$portlist == ""} {
+        # Print information
+        puts "Build Information"
+        puts "- MacPorts Version [macports::version]"
+        puts "- Mac OS X Version ${macports::macosx_version}"
+        puts "- Platform ${macports::os_arch} ${macports::os_platform}"
+        puts "- Build Arch is ${macports::build_arch}"
+        puts "- XCode Version ${macports::xcodeversion}"
+        return 0
+    }
+
+    # Make sure there aren't too many subcommands
+    if {[llength $portlist] > 1} {
+        puts "Please select only one subcommand. See port help stats"
+        return 0
+    }
+
+    # Get the command
+    set cmd [lindex $portlist 0]
+        
+    switch $cmd {
+        "submit" {
+            # Only submit if the user is participating
+            if {[string equal ${macports::stats_participate} "yes"]} {
+                # TODO: proc call which will submit data
+                puts "Will submit collected data"
+            }
+        }
+        default {
+            puts "Unknown subcommand. See port help stats"
+        }
+    }
+    
+    return 0
+}
+
 proc action_dependents { action portlist opts } {
     if {[require_portlist portlist]} {
         return 1
@@ -3782,6 +3820,7 @@
     \
     version     [list action_version        [ACTION_ARGS_NONE]] \
     platform    [list action_platform       [ACTION_ARGS_NONE]] \
+    stats       [list action_stats          [ACTION_ARGS_STRINGS]] \
     \
     uninstall   [list action_uninstall      [ACTION_ARGS_PORTS]] \
     \
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110527/5c9d5fad/attachment-0001.html>


More information about the macports-changes mailing list