[tor-commits] [ooni-probe/master] Dynamically generate the deck hash path.

art at torproject.org art at torproject.org
Fri Feb 28 14:32:21 UTC 2014


commit baed9a2481f591f8139920217d32e02dffff934f
Author: Arturo Filastò <art at fuffa.org>
Date:   Thu Jan 30 19:58:39 2014 +0100

    Dynamically generate the deck hash path.
---
 ooni/deck.py            |    4 ++--
 ooni/tests/test_deck.py |    6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ooni/deck.py b/ooni/deck.py
index 8212c3d..1b5fd72 100644
--- a/ooni/deck.py
+++ b/ooni/deck.py
@@ -17,7 +17,7 @@ from hashlib import sha256
 class InputFile(object):
     def __init__(self, input_hash, base_path=config.inputs_directory):
         self.id = input_hash
-        cache_path = os.path.join(base_path, input_hash)
+        cache_path = os.path.join(os.path.abspath(base_path), input_hash)
         self.cached_file = cache_path
         self.cached_descriptor = cache_path + '.desc'
     
@@ -93,7 +93,7 @@ class Deck(InputFile):
 
         self.oonibclient = OONIBClient(self.bouncer)
 
-        self.decksDirectory = decks_directory
+        self.decksDirectory = os.path.abspath(decks_directory)
         self.deckHash = deck_hash
 
         if deckFile: self.loadDeck(deckFile)
diff --git a/ooni/tests/test_deck.py b/ooni/tests/test_deck.py
index 3a330c0..7c7bc35 100644
--- a/ooni/tests/test_deck.py
+++ b/ooni/tests/test_deck.py
@@ -41,7 +41,7 @@ class BaseTestCase(unittest.TestCase):
             subargs: []
             test_file: %s/dummy_test.py
             testdeck: null
-        """ % self.cwd
+""" % self.cwd
 
 class TestInputFile(BaseTestCase):
     def test_file_cached(self):
@@ -93,8 +93,8 @@ class MockOONIBClient(object):
 class TestDeck(BaseTestCase):
     def setUp(self):
         super(TestDeck, self).setUp()
-        self.deck_file = os.path.join(self.cwd,
-            '4145fd06158ce16e45469fc6b41c3d79a93b958925484ffa93c205d9f3b2e30a')
+        deck_hash = sha256(self.dummy_deck_content).hexdigest()
+        self.deck_file = os.path.join(self.cwd, deck_hash)
         with open(self.deck_file, 'w+') as f:
             f.write(self.dummy_deck_content)
         with open(os.path.join(self.cwd, 'dummy_test.py'), 'w+') as f:





More information about the tor-commits mailing list