Permalink
Browse files

[CHANGED]

   1_extract.sh
      - Switched from ~/Analysis to CWD (current directory) from where the script has been called. All log files will appear in the current directory.

   2_transform.sh
      - Added if-clause in order to distinguish between "gzcat" (Mac OS X) and "zcat" (Ubuntu)

   3_uploader.rb
      - More flexibility through more variables. Variables can now be filled with values coming as script parameters. Will require param checking first.
  • Loading branch information...
1 parent 0eba897 commit 37190cdc43116174c16a38480b58d615d2469ffd @otype committed Dec 25, 2009
Showing with 35 additions and 23 deletions.
  1. +4 −5 postprocessors/1_extract.sh
  2. +9 −7 postprocessors/2_transform.sh
  3. +22 −11 postprocessors/3_uploader.rb
@@ -1,11 +1,10 @@
#!/bin/bash
+CWD=`pwd`
DATE=`date "+%Y%m%d_%H%M%S"`
-LOGFILE="${DATE}.def.g1.log"
-LOGFILEZIP="$LOGFILE.gz"
-NEWZIPFILES="new/$LOGFILE.gz"
-
-cd ~/Analysis
+LOGFILE="$CWD/${DATE}.def.g1.log"
+LOGFILEZIP="$CWD/$LOGFILE.gz"
+NEWZIPFILES="$CWD/$LOGFILE.gz"
echo "[Pulling file from device]"
adb pull /sdcard/def/def.log $LOGFILE
@@ -1,14 +1,16 @@
#/bin/bash
-#for i in *def.g1.log.gz; do gzcat $i | sed 's/^RUN : //' | grep "^{" | sed 's/:nil/\"\"/g' | gzip > clean_$i; done
-
-#for i in *def.g1.log.gz
ARGS="$*"
+
ZCAT="zcat"
-for i in $ARGS
+if [ `uname` == "Darwin" ]; then
+ ZCAT="gzcat
+fi
+
+for arg in $ARGS
do
- echo $i
- $ZCAT $i |
+ echo $arg
+ $ZCAT $arg |
sed 's/^RUN : //' |
grep "^{" |
sed 's/:nil/\"\"/g' |
@@ -17,6 +19,6 @@ do
sed 's/runnable tasks\\\"\\\"/runnable tasks\\\":\\\"/g' |
sed 's/\[0\]\\\"\\\"/\[0\]\\\":\\\"/g' |
sed 's/\\\"\\\"\\\"/\\\":\\\"\\\"/g' |
- gzip > clean_$i
+ gzip > clean_$arg
done
@@ -1,17 +1,28 @@
-#!/usr/bin/env ruby1.9
+#!/usr/bin/env ruby
+# Set input logfile if that file exists
+INPUT_FILE = ARGV[0] if File.exist(ARGV[0])
-#logfile = File.open("logfile.log", "w+")
-file = File.open(ARGV[0])
+# CouchDB information still hardcoded here but easy to change
+COUCHDB_HOST = "localhost"
+COUCHDB_PORT = "5984"
+COUCHD_DATABASE = "defg1test"
-file.each_line do |line|
- cmd = "curl -X POST -d"
- url = "http://localhost:5984/defg1test/"
- whole_command = cmd + " \"" + line.strip + "\" " + url
- # puts whole_command
- ans = system(whole_command)
+# Put together the URL for CouchDB
+COUCHDB_URL = "http://#{COUCHDB_HOST}:#{COUCHDB_PORT}/#{COUCHDB_DATABASE}"
-end
+# Debug flag for verbose output
+DEBUGGING = false
+
+# cUrl command
+CURL_POST = "curl -X POST -d"
+# Run the upload
+file = File.open(INPUT_FILE)
+file.each_line do |line|
+ couchdb_request = CURL_POST + " \"" + line.strip + "\" " + COUCHDB_URL
+ puts couchdb_request if DEBUGGING
+ ans = system(couchdb_request)
+ puts ans if DEBUGGING
+end
file.close
-#logfile.close

0 comments on commit 37190cd

Please sign in to comment.