From 78125db4ea20bf7d9e5288337ca17d2ff157cb80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Fri, 22 Aug 2014 14:52:02 +0200 Subject: [PATCH] Use env variables everywhere --- bin/LAUNCH.sh | 15 +++++++++------ bin/Shutdown.py | 3 ++- bin/packages/Paste.py | 6 ------ installing_deps.sh | 36 ++++++++++++++++-------------------- pip_packages_requirement.txt | 2 +- 5 files changed, 28 insertions(+), 34 deletions(-) diff --git a/bin/LAUNCH.sh b/bin/LAUNCH.sh index 0d71248f..d7424603 100755 --- a/bin/LAUNCH.sh +++ b/bin/LAUNCH.sh @@ -9,10 +9,13 @@ WHITE="\\033[0;02m" YELLOW="\\033[1;33m" CYAN="\\033[1;36m" -#Modify these PATH -export PATH=$(pwd):$PATH -export PATH=/opt/redis-2.8.12/src/:$PATH -export PATH=/opt/redis-leveldb/:$PATH +[ -z "$AIL_HOME" ] && echo "Needs the env var AIL_HOME. Run the script from the virtual environment." && exit 1; +[ -z "$AIL_REDIS" ] && echo "Needs the env var AIL_REDIS. Run the script from the virtual environment." && exit 1; +[ -z "$AIL_LEVELDB" ] && echo "Needs the env var AIL_LEVELDB. Run the script from the virtual environment." && exit 1; + +export PATH=$AIL_HOME:$PATH +export PATH=$AIL_REDIS:$PATH +export PATH=$AIL_LEVELDB:$PATH function helptext { echo -e $YELLOW" @@ -45,7 +48,7 @@ function helptext { } function launching_redis { - conf_dir='/home/user/AIL-framework/configs/' + conf_dir="${AIL_HOME}/configs/" screen -dmS "Redis" sleep 0.1 @@ -60,7 +63,7 @@ function launching_redis { function launching_lvldb { #Want to launch more level_db? lvdbhost='127.0.0.1' - lvdbdir='/home/user/AIL-framework/LEVEL_DB_DATA/' + lvdbdir="${AIL_HOME}/LEVEL_DB_DATA/" db1_y='2013' db2_y='2014' nb_db=13 diff --git a/bin/Shutdown.py b/bin/Shutdown.py index f197e5c8..108801da 100755 --- a/bin/Shutdown.py +++ b/bin/Shutdown.py @@ -22,8 +22,9 @@ Requirements """ import redis import ConfigParser +import os -configfile = './packages/config.cfg' +configfile = os.path.join(os.environ('AIL_BIN'), './packages/config.cfg') def main(): diff --git a/bin/packages/Paste.py b/bin/packages/Paste.py index 52d30521..564dcc7d 100755 --- a/bin/packages/Paste.py +++ b/bin/packages/Paste.py @@ -19,7 +19,6 @@ Conditions to fulfill to be able to use this class correctly: import os import magic import gzip -import pprint import redis import operator import string @@ -376,8 +375,3 @@ class Paste(object): if match != '' and len(match) < 100: matchs.append(match) return matchs - - -if __name__ == "__main__": - pp = pprint.PrettyPrinter(indent=4) - main() diff --git a/installing_deps.sh b/installing_deps.sh index 17c2ac89..e47898a9 100755 --- a/installing_deps.sh +++ b/installing_deps.sh @@ -5,15 +5,8 @@ set -x sudo apt-get update -sudo apt-get install python-pip python-virtualenv python-dev libfreetype6-dev screen - -virtualenv AILENV - -echo export AIL_HOME=$(pwd) >> ./AILENV/bin/activate -echo export AIL_BIN=$(pwd)/bin/ >> ./AILENV/bin/activate -echo export AIL_FLASK=$(pwd)/var/www/ >> ./AILENV/bin/activate - -sudo apt-get install g++ python-tk +sudo apt-get install python-pip python-virtualenv python-dev libfreetype6-dev \ + screen g++ python-tk #Needed for bloom filters sudo apt-get install libssl-dev libfreetype6-dev python-numpy @@ -24,23 +17,13 @@ sudo apt-get install libadns1 libadns1-dev #needed for mathplotlib test ! -L /usr/include/ft2build.h && sudo ln -s freetype2/ft2build.h /usr/include/ -. ./AILENV/bin/activate - -pip install -r pip_packages_requirement.txt --upgrade - -pip install -U textblob -python -m textblob.download_corpora - # REDIS # test ! -d redis/ && git clone https://github.com/antirez/redis.git pushd redis/ git checkout 2.8 -git pull make popd -echo export AIL_REDIS=$(pwd)/src/ >> ./AILENV/bin/activate - # REDIS LEVEL DB # test ! -d redis-leveldb/ && git clone https://github.com/KDr2/redis-leveldb.git pushd redis-leveldb/ @@ -48,7 +31,20 @@ git submodule init git submodule update popd -mkdir -p $AIL_HOME/{PASTES,Blooms,dumps} +virtualenv AILENV +echo export AIL_HOME=$(pwd) >> ./AILENV/bin/activate +echo export AIL_BIN=$(pwd)/bin/ >> ./AILENV/bin/activate +echo export AIL_FLASK=$(pwd)/var/www/ >> ./AILENV/bin/activate +echo export AIL_REDIS=$(pwd)/redis/src/ >> ./AILENV/bin/activate +echo export AIL_LEVELDB=$(pwd)/redis-leveldb/ >> ./AILENV/bin/activate + +. ./AILENV/bin/activate + +mkdir -p $AIL_HOME/{PASTES,Blooms,dumps} mkdir -p $AIL_HOME/LEVEL_DB_DATA/{2014,2013} +pip install -r pip_packages_requirement.txt + +# Download the necessary NLTK corpora +HOME=$(pwd) python -m textblob.download_corpora diff --git a/pip_packages_requirement.txt b/pip_packages_requirement.txt index 5505f554..ef01defb 100644 --- a/pip_packages_requirement.txt +++ b/pip_packages_requirement.txt @@ -4,7 +4,7 @@ pyzmq dnspython logbook pubsublogger - +textblob #Graph numpy