diff options
author | prathamesh | 2016-09-29 15:31:50 +0530 |
---|---|---|
committer | prathamesh | 2016-09-29 15:31:50 +0530 |
commit | 155bff9c2a32192405e21ffdb8f533893eb927f4 (patch) | |
tree | 9b1a625a824ec89da516ced964b869dfb95481ac | |
parent | 64bb8507cbfbaf8b4558926a0c3206eb85547ed1 (diff) | |
download | online_test-155bff9c2a32192405e21ffdb8f533893eb927f4.tar.gz online_test-155bff9c2a32192405e21ffdb8f533893eb927f4.tar.bz2 online_test-155bff9c2a32192405e21ffdb8f533893eb927f4.zip |
Set OUTPUT_DIR path to a temporary directory.
Moved OUTPUT_DIR to settings.
Temporary directory path is fetched, and
accordingly output path is set.
Now, the outpath directory will always have a write permission.
-rw-r--r-- | online_test/settings.py | 3 | ||||
-rw-r--r-- | yaksh/models.py | 9 |
2 files changed, 6 insertions, 6 deletions
diff --git a/online_test/settings.py b/online_test/settings.py index 81fd6a3..5df0410 100644 --- a/online_test/settings.py +++ b/online_test/settings.py @@ -10,8 +10,11 @@ https://docs.djangoproject.com/en/1.6/ref/settings/ from yaksh.pipeline.settings import AUTH_PIPELINE # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os +import tempfile BASE_DIR = os.path.dirname(os.path.dirname(__file__)) +# The directory where user data can be saved. +OUTPUT_DIR = os.path.join(tempfile.gettempdir(), 'output') # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ diff --git a/yaksh/models.py b/yaksh/models.py index 7c4d5c4..69dff6d 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -21,10 +21,7 @@ import zipfile import tempfile from file_utils import extract_files from yaksh.xmlrpc_clients import code_server - - -# The directory where user data can be saved. -OUTPUT_DIR = abspath(join(dirname(__file__), 'output')) +from django.conf import settings languages = ( @@ -205,9 +202,9 @@ class Profile(models.Model): def get_user_dir(self): """Return the output directory for the user.""" - user_dir = join(OUTPUT_DIR, str(self.user.username)) + user_dir = join(settings.OUTPUT_DIR, str(self.user.username)) if not exists(user_dir): - os.mkdir(user_dir) + os.makedirs(user_dir) # Make it rwx by others. os.chmod(user_dir, stat.S_IROTH | stat.S_IWOTH | stat.S_IXOTH | stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |