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

[tor-commits] [ooni-probe/master] * Added a parameter check to make sure that inputFile in nettest.getOptions() is



commit ded25803722e1251bb1a82f9c65beb760f473798
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Thu Oct 11 22:17:19 2012 +0000

    * Added a parameter check to make sure that inputFile in nettest.getOptions() is
      actually a file on the system.
---
 ooni/nettest.py |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ooni/nettest.py b/ooni/nettest.py
index e7ae7d5..85745cc 100644
--- a/ooni/nettest.py
+++ b/ooni/nettest.py
@@ -98,9 +98,16 @@ class TestCase(unittest.TestCase):
         fp.close()
 
     def getOptions(self):
-        if type(self.inputFile) is str:
-            fp = open(self.inputFile)
-            self.inputs = self.inputProcessor(fp)
+        if self.inputFile:
+            try:
+                assert isinstance(self.inputFile, str)
+            except AssertionError, ae:
+                log.err(ae)
+            else:
+                if os.path.isfile(self.inputFile):
+                    print self.inputFile
+                    fp = open(self.inputFile)
+                    self.inputs = self.inputProcessor(fp)
         elif not self.inputs[0]:
             pass
         elif self.inputFile:



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits