Commit 74d24e66 authored by chris's avatar chris
Browse files

Added feature to define custom user and group to set ownership with when

writing files.
parent 3a56c023
#from grp import getgrnam
#from pwd import getpwnam
import os
from django.conf import settings
......@@ -14,3 +16,16 @@ def write_file(name, content, overwrite=False):
if not os.path.isdir(dirs):
open(fqfn, 'wb').write(content)
# Set ownership and permissions.
uname = getattr(settings, 'DATABASE_FILES_USER', None)
gname = getattr(settings, 'DATABASE_FILES_GROUP', None)
if gname:
gname = ':'+gname
if uname:
os.system('chown -RL %s%s "%s"' % (uname, gname, dirs))
# Set permissions.
perms = getattr(settings, 'DATABASE_FILES_PERMS', None)
if perms:
os.system('chmod -R %s "%s"' % (perms, dirs))
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment