[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] [torflow/master 1/8] Fixed system/static BeautifulSoup clashing



Author: John M. Schanck <john@xxxxxxxxxxx>
Date: Sat, 15 May 2010 21:06:29 -0400
Subject: Fixed system/static BeautifulSoup clashing
Commit: 85b8bb65c78202bf8774c41c79199431bbc52349

---
 NetworkScanners/ExitAuthority/libsoat.py     |    5 +++--
 NetworkScanners/ExitAuthority/soat.py        |   25 ++++++++++++++++++++-----
 NetworkScanners/ExitAuthority/soat_config.py |    2 +-
 3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/NetworkScanners/ExitAuthority/libsoat.py b/NetworkScanners/ExitAuthority/libsoat.py
index 1708a69..f612cd2 100644
--- a/NetworkScanners/ExitAuthority/libsoat.py
+++ b/NetworkScanners/ExitAuthority/libsoat.py
@@ -13,9 +13,10 @@ import re
 import copy
 import socket
 import struct
-sys.path.append("../libs")
+
 from OpenSSL import crypto
-from BeautifulSoup.BeautifulSoup import Tag, SoupStrainer
+
+from soat import Tag, SoupStrainer
 
 import sets
 from sets import Set
diff --git a/NetworkScanners/ExitAuthority/soat.py b/NetworkScanners/ExitAuthority/soat.py
index 8bbd1ab..3972cd9 100755
--- a/NetworkScanners/ExitAuthority/soat.py
+++ b/NetworkScanners/ExitAuthority/soat.py
@@ -48,11 +48,26 @@ import Queue
 import threading
 import atexit
 
+# Import the correct BeautifulSoup
+try:
+    # Try system-wide BeautifulSoup
+    from BeautifulSoup import __version__ as BS_version
+except ImportError:
+    # Use static version if it's not found
+    sys.path.insert(0, "../libs/BeautifulSoup")
+else:
+    # For now, if system-wide version is newer than 3.1
+    # use the static version
+    if BS_version.split(".") >= ['3','1','0','0']:
+        del sys.modules['BeautifulSoup']
+        sys.path.insert(0, "../libs/BeautifulSoup")
+from BeautifulSoup import Tag, SoupStrainer, BeautifulSoup
 
-sys.path.append("../../")
 
 from libsoat import *
 
+sys.path.append("../../")
+
 from TorCtl import TorUtil, TorCtl, PathSupport, ScanSupport
 from TorCtl.TorUtil import *
 from TorCtl.PathSupport import *
@@ -64,16 +79,16 @@ from OpenSSL import *
 from soat_config_real import *
 
 
-sys.path.append("../libs/")
+sys.path.insert(0,"../libs")
 
 # Make our SocksiPy use our socket
 __origsocket = socket.socket
 socket.socket = PathSupport.SmartSocket
-from SocksiPy import socks
+import SocksiPy.socks as socks
 socket.socket = __origsocket
 
-from BeautifulSoup.BeautifulSoup import SoupStrainer, Tag
-import Pyssh.pyssh
+
+import Pyssh.pyssh as pyssh
 
 
 # XXX: really need to standardize on $idhex or idhex :(
diff --git a/NetworkScanners/ExitAuthority/soat_config.py b/NetworkScanners/ExitAuthority/soat_config.py
index 77c4a4c..a4762fc 100644
--- a/NetworkScanners/ExitAuthority/soat_config.py
+++ b/NetworkScanners/ExitAuthority/soat_config.py
@@ -10,7 +10,7 @@ import sys
 sys.path.append("../../")
 from TorCtl.PathSupport import *
 
-from BeautifulSoup.BeautifulSoup import BeautifulSoup
+from soat import BeautifulSoup
 
 # Keywords from these files are used  when searching for 'random' urls 
 # for testing. They can be the same file, or different files.
-- 
1.6.5