Scrapy, a fast high-level web crawling & scraping framework for Python.
set write permission to startproject folder
Matthias Meschede0cabf406d5c5
diff --git a/scrapy/commands/startproject.py b/scrapy/commands/startproject.pyindex ebe3a9c2c..cfaa25154 100644--- a/scrapy/commands/startproject.py+++ b/scrapy/commands/startproject.py@@ -4,6 +4,7 @@ import stringfrom importlib import import_modulefrom os.path import join, exists, abspathfrom shutil import ignore_patterns, move, copy2, copystat+import statimport scrapyfrom scrapy.commands import ScrapyCommand@@ -79,6 +80,28 @@ class Command(ScrapyCommand):copy2(srcname, dstname)copystat(src, dst)+ def _set_rw_permissions(self, path):+ """+ Sets permissions of a directory tree to +rw and +rwx for folders.+ This is necessary if the start template files come without write+ permissions.+ """+ mode_rw = (stat.S_IRUSR+ | stat.S_IWUSR+ | stat.S_IRGRP+ | stat.S_IROTH)++ mode_x = (stat.S_IXUSR+ | stat.S_IXGRP+ | stat.S_IXOTH)++ os.chmod(path, mode_rw | mode_x)+ for root, dirs, files in os.walk(path):+ for dir in dirs:+ os.chmod(join(root, dir), mode_rw | mode_x)+ for file in files:+ os.chmod(join(root, file), mode_rw)+def run(self, args, opts):if len(args) not in (1, 2):raise UsageError()@@ -99,6 +122,9 @@ class Command(ScrapyCommand):returnself._copytree(self.templates_dir, abspath(project_dir))++ self._set_rw_permissions(abspath(project_dir))+move(join(project_dir, 'module'), join(project_dir, project_name))for paths in TEMPLATES_TO_RENDER:path = join(*paths)