summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2018-05-04 16:08:30 +0100
committerJames Ennis <james.ennis@codethink.com>2018-05-04 16:08:30 +0100
commit48968a299fa8e63fb71552024ff83be089be1d63 (patch)
tree46f7663e2ac4229684a0b14bf4218512bee6a9d2
parent494f18fe19fa857b6e423129c1f4d83500c6d75f (diff)
downloadbuildstream-jennis/initialise-elements-sub-dir.tar.gz
app.py: Ensure an elements sub-dir is created upon project initialisationjennis/initialise-elements-sub-dir
-rw-r--r--buildstream/_frontend/app.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py
index c32f8c90b..3bcb0d962 100644
--- a/buildstream/_frontend/app.py
+++ b/buildstream/_frontend/app.py
@@ -343,6 +343,7 @@ class App():
directory = self._main_options['directory']
directory = os.path.abspath(directory)
project_path = os.path.join(directory, 'project.conf')
+ elements_path = os.path.join(directory, 'elements')
try:
# Abort if the project.conf already exists, unless `--force` was specified in `bst init`
@@ -371,6 +372,13 @@ class App():
except IOError as e:
raise AppError("Error creating project directory {}: {}".format(directory, e)) from e
+ # Create the elements sub-directory if it doesnt exist
+ try:
+ os.makedirs(elements_path, exist_ok=True)
+ except IOError as e:
+ raise AppError("Error creating elements sub-directory {}: {}"
+ .format(elements_path, e)) from e
+
# Dont use ruamel.yaml here, because it doesnt let
# us programatically insert comments or whitespace at
# the toplevel.