You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2018/02/15 18:48:46 UTC
[airavata-django-portal] 03/04: AIRAVATA-2631 Make sure exp dir
exists and is world writeable
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal.git
commit f92e2ee2e314491b3dd332c9c3a1009215a28542
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Thu Feb 15 12:25:44 2018 -0500
AIRAVATA-2631 Make sure exp dir exists and is world writeable
---
django_airavata/apps/api/datastore.py | 15 ++++++++++-----
django_airavata/settings.py | 2 ++
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/django_airavata/apps/api/datastore.py b/django_airavata/apps/api/datastore.py
index d029b9f..fb09bfa 100644
--- a/django_airavata/apps/api/datastore.py
+++ b/django_airavata/apps/api/datastore.py
@@ -41,7 +41,7 @@ def save(username, project_name, experiment_name, file):
"""Save file to username/project name/experiment_name in data store."""
exp_dir = os.path.join(
experiment_data_storage.get_valid_name(username),
- experiment_data_storage.get_valid_name(project.name),
+ experiment_data_storage.get_valid_name(project_name),
experiment_data_storage.get_valid_name(experiment_name))
file_path = os.path.join(
exp_dir,
@@ -70,12 +70,18 @@ def save(username, project_name, experiment_name, file):
def get_experiment_dir(username, project_name, experiment_name):
- experiment_dir = os.path.join(
- settings.GATEWAY_DATA_STORE_DIR,
+ """Return an experiment directory (full path) for the given experiment."""
+ experiment_dir_name = os.path.join(
experiment_data_storage.get_valid_name(username),
experiment_data_storage.get_valid_name(project_name),
experiment_data_storage.get_valid_name(experiment_name))
- # TODO: make sure experiment_dir has the appropriate permissions and exists
+ experiment_dir = experiment_data_storage.path(experiment_dir_name)
+ if not experiment_data_storage.exists(experiment_dir):
+ os.mkdir(experiment_dir,
+ mode=experiment_data_storage.directory_permissions_mode)
+ # os.mkdir mode isn't always respected so need to chmod to be sure
+ os.chmod(experiment_dir,
+ mode=experiment_data_storage.directory_permissions_mode)
return experiment_dir
@@ -84,7 +90,6 @@ def _get_replica_filepath(data_product):
for rep in data_product.replicaLocations
if rep.replicaLocationCategory ==
ReplicaLocationCategory.GATEWAY_DATA_STORE]
- print(replica_filepaths)
replica_filepath = (replica_filepaths[0]
if len(replica_filepaths) > 0 else None)
if replica_filepath:
diff --git a/django_airavata/settings.py b/django_airavata/settings.py
index aae9bd5..fa5ccd9 100644
--- a/django_airavata/settings.py
+++ b/django_airavata/settings.py
@@ -130,6 +130,8 @@ USE_TZ = True
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, "django_airavata", "static")]
+# Data storage
+FILE_UPLOAD_DIRECTORY_PERMISSIONS = 0o777
# Django REST Framework configuration
REST_FRAMEWORK = {
--
To stop receiving notification emails like this one, please contact
machristie@apache.org.