Ensure filepath exists

Before we can write facter facts of hiera hieras, we need for the
directory to exist.

Change-Id: Id855da44d9e2cb06824ed3507158aeaa466768f7
This commit is contained in:
Monty Taylor 2015-03-12 10:08:44 -04:00
parent 226adc7f23
commit 5faac02239
1 changed files with 2 additions and 1 deletions

View File

@ -88,7 +88,8 @@ def _get_facter_dir():
def _write_structured_data(basedir, basename, data):
# Ensure filepath?
if not os.path.exists(basedir):
os.makedirs(basedir)
file_path = os.path.join(basedir, "{0}.json".format(basename))
with os.fdopen(
os.open(file_path, os.O_CREAT | os.O_WRONLY, 0o600),