mirror of
https://github.com/django/django.git
synced 2025-10-26 15:16:09 +00:00
Fixed #5307 -- startproject/startapp now makes sure all files it creates are writeable. Thanks, Thomas Stromberg
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6028 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.management.color import color_style
|
||||
import sys
|
||||
import os
|
||||
|
||||
class CommandError(Exception):
|
||||
pass
|
||||
@@ -121,7 +122,6 @@ class NoArgsCommand(BaseCommand):
|
||||
|
||||
def copy_helper(style, app_or_project, name, directory, other_name=''):
|
||||
import django
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
other = {'project': 'app', 'app': 'project'}[app_or_project]
|
||||
@@ -157,5 +157,15 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
|
||||
fp_new.close()
|
||||
try:
|
||||
shutil.copymode(path_old, path_new)
|
||||
_make_writeable(path_new)
|
||||
except OSError:
|
||||
sys.stderr.write(style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new))
|
||||
|
||||
def _make_writeable(filename):
|
||||
"Makes sure that the file is writeable. Useful if our source is read-only."
|
||||
import stat
|
||||
if not os.access(filename, os.W_OK):
|
||||
st = os.stat(filename)
|
||||
new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
|
||||
os.chmod(filename, new_permissions)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user