[tor-commits] [ooni-probe/master] Force creation of decks-available directory.

art at torproject.org art at torproject.org
Mon Sep 19 12:14:25 UTC 2016


commit 28a441b1da39b8b8de28752dcfc0578352f6911c
Author: Arturo Filastò <arturo at filasto.net>
Date:   Tue Sep 13 15:28:02 2016 +0200

    Force creation of decks-available directory.
    
    Failing to do so will lead to the decks not being copied over and pip will
    silently fail.
---
 setup.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/setup.py b/setup.py
index 60d08a5..753cf07 100644
--- a/setup.py
+++ b/setup.py
@@ -87,6 +87,7 @@ Have fun!
 from __future__ import print_function
 
 import os
+import errno
 import tempfile
 from glob import glob
 
@@ -147,6 +148,13 @@ def install_lepidopter_update():
     check_call(["data/updater.py", "install"])
 
 
+def mkdir_p(path):
+    try:
+        os.makedirs(path)
+    except OSError as ose:
+        if ose != errno.EEXIST:
+            raise
+
 class OoniInstall(InstallCommand):
     def gen_config(self, share_path):
         config_file = pj(tempfile.mkdtemp(), "ooniprobe.conf.sample")
@@ -183,14 +191,9 @@ class OoniInstall(InstallCommand):
         with open("ooni/settings.ini", "w+") as fp:
             settings.write(fp)
 
-        try:
-            os.makedirs(pj(var_path, 'ooni'))
-        except OSError:
-            pass
-        try:
-            os.makedirs(pj(share_path, 'ooni'))
-        except OSError:
-            pass
+        mkdir_p(pj(var_path, 'ooni'))
+        mkdir_p(pj(share_path, 'ooni'))
+        mkdir_p(pj(share_path, 'ooni', 'decks-available'))
 
     def pre_install(self):
         prefix = os.path.abspath(self.prefix)





More information about the tor-commits mailing list