[tor-commits] [ooni-probe/master] This fixes a broken commit and fixes scripts/before_i_commit.sh

ioerror at torproject.org ioerror at torproject.org
Fri Dec 7 05:22:30 UTC 2012


commit 47c345d0274f34ec28d318603f6f39b6cb081106
Author: Jacob Appelbaum <jacob at appelbaum.net>
Date:   Fri Dec 7 11:49:23 2012 +0630

    This fixes a broken commit and fixes scripts/before_i_commit.sh
    
    Normally, I would not put two fixes into one commit - however, git master
    was broken. The fix in txscapy.py fixes it such that I can run tests at all.
    The fix in scripts/before_i_commit.sh allows me to actually run the thing.
    It now depends on bash and as a result, it works properly. If we actually
    want this this to run on an older unix machine, such a user can fix it to work
    with a /bin/sh that isn't based on bash or later implementations.
    
    The previous version of scripts/before_i_commit.sh erased all .yamloo files
    and as a result, erased a lot of import data. If we run tests, we should not
    ever erase the data automatically.
---
 ooni/utils/txscapy.py      |    2 +-
 scripts/before_i_commit.sh |   21 +++++++++++++++++----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ooni/utils/txscapy.py b/ooni/utils/txscapy.py
index fc021f1..62bde94 100644
--- a/ooni/utils/txscapy.py
+++ b/ooni/utils/txscapy.py
@@ -22,6 +22,7 @@ try:
     from scapy.arch import pcapdnet
 
     config.pcap_dnet = True
+    from scapy.all import Gen, SetGen, MTU
 
 except ImportError, e:
     log.err("pypcap or dnet not installed. "
@@ -86,7 +87,6 @@ class ScapyFactory(abstract.FileDescriptor):
     https://github.com/enki/muXTCP/blob/master/scapyLink.py
     """
     def __init__(self, interface, super_socket=None, timeout=5):
-        from scapy.all import Gen, SetGen, MTU
 
         abstract.FileDescriptor.__init__(self, reactor)
         if interface == 'auto':
diff --git a/scripts/before_i_commit.sh b/scripts/before_i_commit.sh
index 69975ff..918b137 100755
--- a/scripts/before_i_commit.sh
+++ b/scripts/before_i_commit.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # This script should be run before you commit to verify that the basic tests
 # are working as they should
 # Once you have run it you can inspect the log file via
@@ -10,10 +10,24 @@
 # rm *.yamloo; rm before_i_commit.log
 #
 
-rm before_i_commit.log
+if [ -f before_i_commit.log ];
+then
+  # this is technically the date it was moved, not the date it was created
+  mv before_i_commit.log before_i_commit-`date +%s`.log;
+  touch before_i_commit.log;
+else
+  touch before_i_commit.log;
+fi
 
 find . -type f -name "*.py[co]" -delete
 
+if [ -f env/bin/activate ];
+then
+  source env/bin/activate;
+else
+  echo "Assuming that your virtual environment is pre-configured...";
+fi
+
 ./bin/ooniprobe -i decks/before_i_commit.testdeck
 
 echo "Below you should not see anything"
@@ -25,5 +39,4 @@ echo "Read through the log file and fix it."
 echo "If you are having some problems fixing some things that have to do with"
 echo "the core of OONI, let's first discuss it on IRC, or open a ticket"
 read
-cat *yamloo | less
-rm -f *yamloo
+#cat *.yamloo | less



More information about the tor-commits mailing list