[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [ooni-probe/master] * Added a startup script for running the old ooniprobe.py directly without
commit 1d827ef0ae1ff4cd5236e60fecab05cfcaa4e464
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date: Thu Oct 11 22:59:32 2012 +0000
* Added a startup script for running the old ooniprobe.py directly without
installing, including detecting our current working directory and
dynamically adding the correct path to $PYTHONPATH, only if that path isn't
present already.
---
bin/old_ooniprobe | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 80 insertions(+), 0 deletions(-)
diff --git a/bin/old_ooniprobe b/bin/old_ooniprobe
new file mode 100755
index 0000000..e234587
--- /dev/null
+++ b/bin/old_ooniprobe
@@ -0,0 +1,80 @@
+#!/bin/bash
+##############################################################################
+#
+# ooniprobe
+# -------------------
+# Setup environment variables and launch /ooni/ooniprobe.py without
+# installing.
+#
+#-----------------------------------------------------------------------------
+# :authors: Isis Lovecruft, Arturo Filasto
+# :license: see included LICENSE file
+# :version: 0.0.1-pre-alpha
+#
+##############################################################################
+
+OONI_EXEC="ooniprobe.py"
+#OONI_EXEC="oonicli.py"
+OONI_PROCESS_NAME=$(echo $OONI_EXEC | sed s/\.py//)
+
+OONI_SCRIPT_IS_HERE=$(dirname ${BASH_SOURCE[0]})
+OONI_BIN="$(cd $OONI_SCRIPT_IS_HERE && pwd)"
+OONI_REPO="$(cd $OONI_BIN"/.." && pwd)"
+OONI_DIR="$OONI_REPO/ooni"
+
+OONI_PATH_ALREADY_SET=false
+
+function usage() {
+ echo "$0 - A simple wrapper around ooniprobe and oonicli to set"
+ echo "up environment variables, so that it can be run without installation."
+ echo;
+ echo "Usage: $0 [oonitest || file || script] [options]"
+ echo "All options and parameters are passed directly to ooniprobe, do"
+ echo "ooniprobe.py --help to see more."
+ echo;
+}
+
+function check_pythonpath_for_ooni() {
+ pythonpaths="$(echo $PYTHONPATH | cut -d ':' -f '1-' --output-delimiter=' ')"
+ for dir in $pythonpaths; do
+ if [[ "x$dir" == "x$OONI_REPO" ]]; then
+ export OONI_PATH_ALREADY_SET=true
+ else
+ continue
+ fi
+ done
+}
+
+function add_ooni_to_pythonpath() {
+ if test ! $OONI_PATH_ALREADY_SET ; then
+ echo "Appending $OONI_REPO to PYTHONPATH..."
+ export PYTHONPATH=$PYTHONPATH:$OONI_REPO
+ fi
+}
+
+function add_exec_dir_to_stack() {
+ cwd_ending=$(echo $(pwd) | awk -F/ '{print $NF}')
+ if [[ "x$cwd_ending" == "xooni" ]]; then
+ pushd $(pwd) 2&>/dev/null ## $(dirs -l -p -1)
+ else
+ pushd $OONI_DIR 2&>/dev/null
+ fi
+ export OONI_RUN_PATH="$(popd)/$OONI_EXEC"
+}
+
+function run_ooni_in_background() {
+ ## :param $1:
+ ## The full path to the script to run, i.e. $OONI_RUN_PATH.
+ coproc $1
+}
+
+if [[ "x$#" == "x0" ]]; then
+ usage
+else
+ check_pythonpath_for_ooni
+ add_ooni_to_pythonpath
+ add_exec_dir_to_stack
+ OONI_START_CMD="python "$OONI_DIR"/"$OONI_EXEC" $@"
+ #run_ooni_in_background $OONI_START_CMD
+ $($OONI_START_CMD)
+fi
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits