Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 """Store the results.
7 Use a db, but we could do better"""
9 import shelve
10 import string
12 class results:
13 def __init__(self, id):
14 self.id = id
15 self.d = shelve.open("data/"+id+".db")
17 def get_tester(self, path):
18 import BaseTest
20 try:
21 fname = path+"tester.py"
22 text = open(fname).read()
23 # Thanks to markh, for showing me how to do this
24 # Python Is Cool.
25 codeob = compile(text, fname, "exec")
26 namespace = { 'BaseTester': BaseTest.tester }
27 exec codeob in namespace, namespace
28 tester = namespace['tester']()
29 except IOError:
30 tester = BaseTest.tester()
32 if self.d.has_key(path):
33 tester.__dict__ = self.d[path]
34 else:
35 tester.parse_config(open(path+"config"))
37 return tester
39 def set_tester(self, path, test):
40 self.d[path] = test.__dict__
42 def write_report(self, file):
43 for i in self.d.keys():
44 file.write("%s: " % (i))
45 tester = self.get_tester(i)
46 res, detail = tester.result()
47 if res:
48 file.write("Pass!\n")
49 else:
50 file.write("Fail: %s\n" % (detail))
52 def __del__(self):
53 self.d.close()