Ticket #4282: django-4282.diff

File django-4282.diff, 1.5 KB (added by Fredrik Lundh <fredrik@…>, 8 years ago)

Updated patch, against revision 6281.

  • django/core/management/base.py

     
    165165def copy_helper(style, app_or_project, name, directory, other_name=''):
    166166    import django
    167167    import re
    168     import shutil
    169168    other = {'project': 'app', 'app': 'project'}[app_or_project]
    170169    if not re.search(r'^\w+$', name): # If it's not a valid directory name.
    171170        raise CommandError("%r is not a valid %s name. Please use only numbers, letters and underscores." % (name, app_or_project))
     
    198197            fp_old.close()
    199198            fp_new.close()
    200199            try:
    201                 shutil.copymode(path_old, path_new)
     200                _copy_execute_permission(path_old, path_new)
    202201                _make_writeable(path_new)
    203202            except OSError:
    204203                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))
     
    214213        new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
    215214        os.chmod(filename, new_permissions)
    216215
     216def _copy_execute_permission(path_old, path_new):
     217    import stat
     218    if hasattr(os, 'chmod'):
     219        st = os.stat(path_old)
     220        mode = stat.S_IMODE(st.st_mode)
     221        if mode & 0111:
     222            new_mode = stat.S_IMODE(os.stat(path_new).st_mode)
     223            os.chmod(path_new, new_mode | 0111)
Back to Top