Ticket #4282: 4282_against_16741.diff

File 4282_against_16741.diff, 1.6 KB (added by Peter Baumgartner, 13 years ago)
  • django/core/management/base.py

    diff --git a/django/core/management/base.py b/django/core/management/base.py
    index 6b9ce6e..a509d6f 100644
    a b def copy_helper(style, app_or_project, name, directory, other_name=''):  
    370370    # other_name -- When copying an application layout, this should be the name
    371371    #               of the project.
    372372    import re
    373     import shutil
    374373    other = {'project': 'app', 'app': 'project'}[app_or_project]
    375374    if not re.search(r'^[_a-zA-Z]\w*$', name): # If it's not a valid directory name.
    376375        # Provide a smart error message, depending on the error.
    def copy_helper(style, app_or_project, name, directory, other_name=''):  
    410409            fp_old.close()
    411410            fp_new.close()
    412411            try:
    413                 shutil.copymode(path_old, path_new)
     412                _copy_execute_permission(path_old, path_new)
    414413                _make_writeable(path_new)
    415414            except OSError:
    416415                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))
    417416
     417def _copy_execute_permission(path_old, path_new):
     418    """
     419    Copy files respecting the user's umask if supported by the OS
     420   
     421    """
     422    import stat
     423    if hasattr(os, 'chmod'):
     424        st = os.stat(path_old)
     425        mode = stat.S_IMODE(st.st_mode)
     426        if mode & 0111:
     427            new_mode = stat.S_IMODE(os.stat(path_new).st_mode)
     428            os.chmod(path_new, new_mode | 0111)
     429
    418430def _make_writeable(filename):
    419431    """
    420432    Make sure that the file is writeable. Useful if our source is
Back to Top