From: Adriana Draghici Date: Sat, 14 Nov 2009 16:03:55 +0000 (+0000) Subject: Tribler: added scripts that modify the sources in order to provide logging information. X-Git-Tag: getopt_long~258 X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=1f70aee0b56a869bfb543ca312cb4edc4139c2af;p=cs-p2p-next.git Tribler: added scripts that modify the sources in order to provide logging information. --- diff --git a/tribler-mod/scrips/README b/tribler-mod/scrips/README new file mode 100644 index 0000000..da8f2bd --- /dev/null +++ b/tribler-mod/scrips/README @@ -0,0 +1,28 @@ + + +===== Scripturi ======== + +1. modify_all_print.sh - adauga in instructiunile print din toate fisierele sursa, informatii legate de timp. +2. print_timestamp.sh - adauga in instructiunile print informatii legate de timp. + - caile catre fisierele sursa modificate sunt scrise intr-un fisier dat ca argument scriptului. +3. set_DEBUG.sh - seteaza DEBUG pe true +4. set_DEBUG_NORMAL.sh - seteaza DEBUG_NORMAL pe true + +Exemplu: + +./print_timestamp.sh modified_files_DEBUG +./set_DEBUG.sh t modified_files_DEBUG +./set_DEBUG_NORMAL.sh t modified_files_DEBUG_NORMAL + + +5. make_changes.sh - modifica instr print din toate fisierele, face schimbarile legate de flag-urile DEBUG + si DEBUG_NORMAL in fisierele listate in modified_files_DEBUG, respectiv modified_files_DEBUG_NORMAL. + +6. undo_changes.sh - aduce sursele la forma in care erau inaintea rularii scripturilor de modificare. + + + +Fisierele modified_files_* contin pe fiecare linie calea catre un fisier ce trebuie modificat. +Liniile care nu contin cel putin un "/" sunt ignorate. + + diff --git a/tribler-mod/scrips/make_changes.sh b/tribler-mod/scrips/make_changes.sh new file mode 100755 index 0000000..fde5fac --- /dev/null +++ b/tribler-mod/scrips/make_changes.sh @@ -0,0 +1,7 @@ +# Modifies tribler sources to output logging information. + +./modify_all_print.sh +./set_DEBUG.sh t modified_files_DEBUG +./set_DEBUG_NORMAL.sh t modified_files_DEBUG_NORMAL + + diff --git a/tribler-mod/scrips/modified_files b/tribler-mod/scrips/modified_files_DEBUG similarity index 100% rename from tribler-mod/scrips/modified_files rename to tribler-mod/scrips/modified_files_DEBUG diff --git a/tribler-mod/scrips/modified_files_DEBUG_NORMAL b/tribler-mod/scrips/modified_files_DEBUG_NORMAL new file mode 100644 index 0000000..e685b55 --- /dev/null +++ b/tribler-mod/scrips/modified_files_DEBUG_NORMAL @@ -0,0 +1,2 @@ +./Tribler/Core/BitTornado/BT1/Connecter.py + diff --git a/tribler-mod/scrips/modify.sh b/tribler-mod/scrips/modify.sh deleted file mode 100755 index 40d35ee..0000000 --- a/tribler-mod/scrips/modify.sh +++ /dev/null @@ -1,2 +0,0 @@ - -for i in $(find -name '*.py' -type f | grep -v '.svn'); do sed -i.bak 's/print >>sys.stderr,/print >>sys.stderr, strftime("%d-%m-%Y %H:%M:%S", localtime())," ",/g' $i; sed -i.bak '1i\from time import localtime, strftime\n' $i; done; diff --git a/tribler-mod/scrips/modify_Connecter.sh b/tribler-mod/scrips/modify_Connecter.sh new file mode 100755 index 0000000..c74e99f --- /dev/null +++ b/tribler-mod/scrips/modify_Connecter.sh @@ -0,0 +1,3 @@ + +sed -i.bak 's/print[ \t]\'/print >>sys.strderr, \'/g' Tribler/Core/BitTornado/BT1/Connecter.py; + diff --git a/tribler-mod/scrips/modify_all_print.sh b/tribler-mod/scrips/modify_all_print.sh new file mode 100755 index 0000000..69e3a44 --- /dev/null +++ b/tribler-mod/scrips/modify_all_print.sh @@ -0,0 +1,2 @@ +# Modifies all print instructions in order to output time information. +for i in $(find -name '*.py' -type f | grep -v '.svn'); do sed -i.bak 's/print[ \t]*>>sys.stderr,/print >>sys.stderr, strftime("%d-%m-%Y %H:%M:%S", localtime())," ",/g' $i; sed -i.bak '1i\from time import localtime, strftime' $i; done; diff --git a/tribler-mod/scrips/print_timestamp.sh b/tribler-mod/scrips/print_timestamp.sh new file mode 100755 index 0000000..01dad8e --- /dev/null +++ b/tribler-mod/scrips/print_timestamp.sh @@ -0,0 +1,18 @@ + +# Modifies print instructions in given files in order to output time information. +if test $# -lt 2 -o \( "-$1" != "-a" -a "-$1" != "-d" \) +then + echo "Usage: ";echo "$0 a - adds timestamp to print instructions in the source files listed in " + echo "$0 d - removes timestamp from print instructions in the source files listed in " +else +# for i in $(cat $2 | grep "/");do echo $i; done; + if test "-$1" == "-a" + then + for i in $(cat $2 | grep "/"); do sed -i.bak 's/print[ \t]*>>sys.stderr,/print >>sys.stderr, strftime("%d-%m-%Y %H:%M:%S", localtime())," ",/g' $i; sed -i.bak '1i\from time import localtime, strftime' $i; done; + else + for i in $(cat $2 | grep "/"); do sed -i.bak 's/print >>sys.stderr, strftime("%d-%m-%Y %H:%M:%S", localtime())," ",/print >>sys.stderr, /g' $i; sed -i.bak '1s/from time import localtime, strftime/ /;t' $i; done; + fi +fi + + + diff --git a/tribler-mod/scrips/set_DEBUG_NORMAL.sh b/tribler-mod/scrips/set_DEBUG_NORMAL.sh new file mode 100755 index 0000000..d79f4d7 --- /dev/null +++ b/tribler-mod/scrips/set_DEBUG_NORMAL.sh @@ -0,0 +1,16 @@ + + +if test $# -lt 2 -o \( "-$1" != "-f" -a "-$1" != "-t" \) +then + echo "Usage: ";echo "$0 t - changes DEBUG_NORMAL_MSGS variable to True for the source files listed in " + echo "$0 f - changes DEBUG_NORMAL_MSGS variable to False for the source files listed in " +else + if test "-$1" == "-t" + then + for i in $(cat $2 | grep "/"); do sed -i.bak 's/DEBUG_NORMAL_MSGS[ \t]*=[ \t]*False[ \t]*[#a-zA-Z ]*/DEBUG_NORMAL_MSGS = True #False/g' $i; done; + else + for i in $(cat $2 | grep "/"); do sed -i.bak 's/DEBUG_NORMAL_MSGS[ \t]*=[ \t]*True[ \t]*[#a-zA-Z ]*/DEBUG_NORMAL_MSGS = False #True/g' $i; done; + fi +fi + + diff --git a/tribler-mod/scrips/undo_changes.sh b/tribler-mod/scrips/undo_changes.sh new file mode 100755 index 0000000..ca8c410 --- /dev/null +++ b/tribler-mod/scrips/undo_changes.sh @@ -0,0 +1,7 @@ + +./unmodify_all_print.sh +./set_DEBUG.sh f modified_files_DEBUG +./set_DEBUG_NORMAL.sh f modified_files_DEBUG_NORMAL + + + diff --git a/tribler-mod/scrips/unmodify.sh b/tribler-mod/scrips/unmodify.sh deleted file mode 100755 index cc6636a..0000000 --- a/tribler-mod/scrips/unmodify.sh +++ /dev/null @@ -1,2 +0,0 @@ -for i in $(find -name '*.py' -type f | grep -v '.svn'); do sed -i.bak 's/print >>sys.stderr, strftime("%d %m %Y %H:%M:%S", localtime())," ",/print >>sys.stderr, /g' $i; sed -i.bak 's/from time import localtime, strftime\n/ /g' $i; done; - diff --git a/tribler-mod/scrips/unmodify_all_print.sh b/tribler-mod/scrips/unmodify_all_print.sh new file mode 100755 index 0000000..f887484 --- /dev/null +++ b/tribler-mod/scrips/unmodify_all_print.sh @@ -0,0 +1,2 @@ +for i in $(find -name '*.py' -type f | grep -v '.svn'); do sed -i.bak 's/print >>sys.stderr, strftime("%d-%m-%Y %H:%M:%S", localtime())," ",/print >>sys.stderr,/g' $i; sed -i.bak '1s/from time import localtime, strftime/ /;t' $i; done; +