allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [16/17] git commit: [#6692] add verbose mode; use comma-separation for tools
Date Thu, 31 Oct 2013 22:05:11 GMT
[#6692] add verbose mode; use comma-separation for tools


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/02a26750
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/02a26750
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/02a26750

Branch: refs/heads/master
Commit: 02a267509e9748b2293107b2411cc6c723d5bddb
Parents: 4d649c0
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
Authored: Thu Oct 31 21:37:34 2013 +0000
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Oct 31 22:04:44 2013 +0000

----------------------------------------------------------------------
 scripts/project_export | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/02a26750/scripts/project_export
----------------------------------------------------------------------
diff --git a/scripts/project_export b/scripts/project_export
index d15d02e..bcb2bc1 100755
--- a/scripts/project_export
+++ b/scripts/project_export
@@ -6,6 +6,7 @@ PROJECT=''
 TOOLS=''
 HOST='sourceforge.net'
 OUTPUT=.
+VERBOSE=false
 
 MAX_MINUTES=10
 HEADERS=/tmp/project_export_response_headers
@@ -16,10 +17,10 @@ function error() {
     exit 1
 }
 
-while getopts "ht:u:o:H:c:" opt; do
+while getopts "ht:u:o:H:c:v" opt; do
     case $opt in
         h)
-            echo "Usage: $0 [OPTION]... PROJECT TOOLS..."
+            echo "Usage: $0 [OPTION]... PROJECT TOOL,TOOL,TOOL,..."
             echo "Schedule an export of PROJECT and retrieve the file when ready"
             echo
             echo "  -c CONFIG_FILE    Load config (optionally including PROJECT and TOOLs)
from file"
@@ -27,9 +28,11 @@ while getopts "ht:u:o:H:c:" opt; do
             echo "  -o OUTPUT         Directory and/or filename for downloaded export file"
             echo "  -t ACCESS_TOKEN   Access (bearer) token for the API"
             echo "  -u USER_NAME      Username associated with access token (to download
file)"
+            echo "  -v                Verbose mode"
             echo "  -h                Show this help message"
             echo
-            echo "The TOOLS should be one or more tool mount-point names, separated by spaces"
+            echo "The TOOLS should be one or more tool mount-point names, separated by commas"
+            exit
             ;;
         t)
             C_ACCESS_TOKEN="$OPTARG"
@@ -43,6 +46,9 @@ while getopts "ht:u:o:H:c:" opt; do
         o)
             C_OUTPUT="$OPTARG"
             ;;
+        v)
+            C_VERBOSE=true
+            ;;
         c)
             source "$OPTARG"
             ;;
@@ -55,6 +61,7 @@ done
 [ -n "$C_USER_NAME" ] && USER_NAME="$C_USER_NAME"
 [ -n "$C_HOST" ] && HOST="$C_HOST"
 [ -n "$C_OUTPUT" ] && OUTPUT="$C_OUTPUT"
+[ -n "$C_VERBOSE" ] && VERBOSE="$C_VERBOSE"
 shift $(($OPTIND - 1))
 if [[ $# -ge 1 ]]; then
     PROJECT="$1"
@@ -67,13 +74,17 @@ fi
 [ -z "$PROJECT" ] && read -p "Project: " PROJECT
 [ -z "$TOOLS" ] && read -p "Tools: " TOOLS
 
+curl_s='-s'
+$VERBOSE && curl_s=''
+
 URL="https://$HOST/rest/p/$PROJECT/admin/export"
 
 function json() {
     python -c "import sys, json;  print json.load(sys.stdin)['$1']"
 }
 
-curl -s -D $HEADERS -o $BODY --data "access_token=$ACCESS_TOKEN&tools=$TOOLS" "$URL"
+$VERBOSE && echo "Posting to $URL"
+curl $curl_s -D $HEADERS -o $BODY --data "access_token=$ACCESS_TOKEN&tools=$TOOLS" "$URL"
|| error "Running curl failed"
 head -n1 $HEADERS | grep 400 && error "Invalid or missing tool"
 head -n1 $HEADERS | grep 503 && error "Export already in progress"
 head -n1 $HEADERS | grep -v 200 && error "Error: $(head -n1 $HEADERS)"
@@ -82,13 +93,17 @@ filename=`cat $BODY | json filename`
 
 minutes=0
 while true; do
-    curl -s -D $HEADERS -o $BODY "${URL}_status?access_token=$ACCESS_TOKEN"
+    $VERBOSE && echo "Checking $URL_status"
+    curl $curl_s -D $HEADERS -o $BODY "${URL}_status?access_token=$ACCESS_TOKEN" || error
"Running curl failed"
     head -n1 $HEADERS | grep -v 200 && error "Error: $(head -n1 $HEADERS)"
     status=`cat $BODY | json status`
+    $VERBOSE && echo "Status: $status"
     [ "$status" == "ready" ] && break
     sleep 60
     let minutes+=1
     [ "$minutes" -ge "$MAX_MINUTES" ] && error "Timeout waiting for export"
 done
 
-scp $USER_NAME@web.$HOST:/home/project-exports/$PROJECT/$filename $OUTPUT
+CMD="scp $USER_NAME@web.$HOST:/home/project-exports/$PROJECT/$filename $OUTPUT"
+$VERBOSE && echo "Running $CMD"
+$CMD


Mime
View raw message