]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
iputil: use the subprocess module instead of os.popen
authorBrian Warner <warner@lothar.com>
Thu, 8 Mar 2007 02:29:00 +0000 (19:29 -0700)
committerBrian Warner <warner@lothar.com>
Thu, 8 Mar 2007 02:29:00 +0000 (19:29 -0700)
src/allmydata/util/iputil.py

index f849b00071f1f2d73f334937edd35339c3350317..f41b3dcda33ec3127c2c8fa503b9bb0b68e2a0a0 100644 (file)
@@ -1,10 +1,10 @@
 
 # adapted from nattraverso.ipdiscover
 
-import os
-from cStringIO import StringIO
+import subprocess
 import re
 import socket
+from cStringIO import StringIO
 from twisted.internet import reactor
 from twisted.internet.protocol import DatagramProtocol
 from twisted.internet.utils import getProcessOutput
@@ -18,7 +18,10 @@ def get_local_addresses():
     # lines.
 
     cmd = "/sbin/ifconfig"
-    p = os.popen(cmd)
+    #p = os.popen(cmd)
+    c = subprocess.Popen(["ifconfig"], stdout=subprocess.PIPE)
+    output = c.communicate()[0]
+    p = StringIO(output)
     addresses = []
     for line in p.readlines():
         # linux shows: "   inet addr:1.2.3.4  Bcast:1.2.3.255..."