Scrapy, a fast high-level web crawling & scraping framework for Python.
get_spider_list_from_eggfile(): more improvements to error messages, and support passing eggruner module as argument
Pablo Hoffmande4909faca75
diff --git a/scrapyd/eggutils.py b/scrapyd/eggutils.pyindex d5bda5197..a05a45ce7 100644--- a/scrapyd/eggutils.py+++ b/scrapyd/eggutils.py@@ -4,7 +4,7 @@ import os, sys, shutil, pkg_resourcesfrom subprocess import Popen, PIPEfrom tempfile import NamedTemporaryFile, mkdtemp-def get_spider_list_from_eggfile(eggfile, project):+def get_spider_list_from_eggfile(eggfile, project, eggrunner='scrapyd.eggrunner'):# FIXME: we use a temporary directory here to avoid permissions problems# when running as system service, as "scrapy list" command tries to write# the scrapy.db sqlite database in current directory@@ -14,15 +14,15 @@ def get_spider_list_from_eggfile(eggfile, project):shutil.copyfileobj(eggfile, f)f.flush()eggfile.seek(0)- pargs = [sys.executable, '-m', 'scrapyd.eggrunner', 'list']+ pargs = [sys.executable, '-m', eggrunner, 'list']env = os.environ.copy()env['SCRAPY_PROJECT'] = projectenv['SCRAPY_EGGFILE'] = f.nameproc = Popen(pargs, stdout=PIPE, stderr=PIPE, cwd=tmpdir, env=env)out, err = proc.communicate()if proc.returncode:- msg = err.splitlines()[-1] if err else "unknown error"- raise RuntimeError(msg)+ msg = err or out or 'unknown error'+ raise RuntimeError(msg.splitlines()[-1])return out.splitlines()finally:shutil.rmtree(tmpdir)