[tor-commits] [ooni-probe/master] Make pypcap a soft dependency
art at torproject.org
art at torproject.org
Thu Dec 6 22:27:20 UTC 2012
commit 7fa1cdf3339fcf0010b598642cdcd9b18e602868
Author: Arturo Filastò <art at fuffa.org>
Date: Thu Dec 6 23:25:59 2012 +0100
Make pypcap a soft dependency
* Update before_i_commit script to point to the new test deck location
---
ooni/utils/txscapy.py | 16 ++++++++++++----
scripts/before_i_commit.sh | 2 +-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/ooni/utils/txscapy.py b/ooni/utils/txscapy.py
index c9cc87a..fc021f1 100644
--- a/ooni/utils/txscapy.py
+++ b/ooni/utils/txscapy.py
@@ -31,10 +31,16 @@ except ImportError, e:
conf.use_pcap = False
conf.use_dnet = False
- from scapy.all import PcapWriter
+ class DummyPcapWriter:
+ def __init__(self, pcap_filename, *arg, **kw):
+ log.err("Initializing DummyPcapWriter. We will not actually write to a pcapfile")
+
+ def write(self):
+ pass
+
+ PcapWriter = DummyPcapWriter
+
-from scapy.all import BasePacketList, conf, PcapReader
-from scapy.all import conf, Gen, SetGen, MTU
def getNetworksFromRoutes():
""" Return a list of networks from the routing table """
@@ -80,6 +86,8 @@ 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':
interface = getDefaultIface()
@@ -146,7 +154,7 @@ class ScapyProtocol(object):
class ScapySender(ScapyProtocol):
timeout = 5
-
+
# This deferred will fire when we have finished sending a receiving packets.
# Should we look for multiple answers for the same sent packet?
multi = False
diff --git a/scripts/before_i_commit.sh b/scripts/before_i_commit.sh
index 8b8180f..69975ff 100755
--- a/scripts/before_i_commit.sh
+++ b/scripts/before_i_commit.sh
@@ -14,7 +14,7 @@ rm before_i_commit.log
find . -type f -name "*.py[co]" -delete
-./bin/ooniprobe -i before_i_commit.testdeck
+./bin/ooniprobe -i decks/before_i_commit.testdeck
echo "Below you should not see anything"
echo "---------------------------------"
More information about the tor-commits
mailing list