Skip to content

Commit

Permalink
couple of fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
stolarczyk committed Aug 1, 2019
1 parent 64383e1 commit 08965e6
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ubiquerg/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def is_command_callable(cmd):
return not bool(os.system(check))


def _is_writeable(folder, check_exist=False, create=False):
def is_writeable(folder, check_exist=False, create=False):
"""
Make sure a folder is writable.
Expand All @@ -44,13 +44,11 @@ def _is_writeable(folder, check_exist=False, create=False):

if os.path.exists(folder):
return os.access(folder, os.W_OK) and os.access(folder, os.X_OK)
elif create_folder:
elif create:
os.mkdir(folder)
elif check_exist:
raise OSError("Folder not found: {}".format(folder))
else:
_LOGGER.debug("Folder not found: {}".format(folder))
# The folder didn't exist. Recurse up the folder hierarchy to make sure
# all paths are writable
return _is_writeable(os.path.dirname(folder), strict_exists)

return is_writeable(os.path.dirname(folder), check_exist)

0 comments on commit 08965e6

Please sign in to comment.