diff options
author | drebs <drebs@leap.se> | 2013-05-03 17:20:34 -0300 |
---|---|---|
committer | drebs <drebs@leap.se> | 2013-05-03 17:20:34 -0300 |
commit | 54e463be00de78a336f4e547634a77faf6a60b37 (patch) | |
tree | b1645b01f824118a0fdf42195f756ac1f9870770 /src/leap | |
parent | a66c472b09015c4310519bc71eeef925d9041de6 (diff) |
Use mkdir_p from leap.common.
Diffstat (limited to 'src/leap')
-rw-r--r-- | src/leap/soledad/__init__.py | 13 | ||||
-rw-r--r-- | src/leap/soledad/tests/test_couch.py | 7 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/leap/soledad/__init__.py b/src/leap/soledad/__init__.py index 2138e14e..b87dbbb6 100644 --- a/src/leap/soledad/__init__.py +++ b/src/leap/soledad/__init__.py @@ -42,6 +42,7 @@ from hashlib import sha256 from leap.common import events from leap.common.check import leap_assert +from leap.common.files import mkdir_p from leap.soledad.backends import sqlcipher from leap.soledad.backends.leap_backend import ( LeapDocument, @@ -254,19 +255,15 @@ class Soledad(object): def _init_dirs(self): """ Create work directories. + + @raise OSError: in case file exists and is not a dir. """ paths = map( lambda x: os.path.dirname(x), [self.local_db_path, self.secret_path]) for path in paths: - if not os.path.isfile(path): - if not os.path.isdir(path): - logger.info('Creating directory: %s.' % path) - os.makedirs(path) - else: - logger.info('Using existent directory: %s.' % path) - else: - raise NotADirectory(path) + logger.info('Creating directory: %s.' % path) + mkdir_p(path) def _init_keys(self): """ diff --git a/src/leap/soledad/tests/test_couch.py b/src/leap/soledad/tests/test_couch.py index 9ac07f88..d6b9ad83 100644 --- a/src/leap/soledad/tests/test_couch.py +++ b/src/leap/soledad/tests/test_couch.py @@ -24,6 +24,9 @@ import re import copy import shutil from base64 import b64decode + +from leap.common.files import mkdir_p + from leap.soledad.backends import couch from leap.soledad.tests import u1db_tests as tests from leap.soledad.tests.u1db_tests import test_backends @@ -77,8 +80,8 @@ class CouchDBWrapper(object): handle.close() # create the dirs from the template - os.mkdir(os.path.join(self.tempdir, 'lib')) - os.mkdir(os.path.join(self.tempdir, 'log')) + mkdir_p(os.path.join(self.tempdir, 'lib')) + mkdir_p(os.path.join(self.tempdir, 'log')) args = ['couchdb', '-n', '-a', confPath] #null = open('/dev/null', 'w') self.process = subprocess.Popen( |