diff --git a/.travis.yml b/.travis.yml index 2e0a82b27..dd93fba70 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: install: - pip install --use-mirrors -r .travis/requirements-$BUILDENV.txt script: - - trial scrapy scrapyd + - trial scrapy notifications: - irc: - "irc.freenode.org#scrapy" diff --git a/MANIFEST.in b/MANIFEST.in index e49beddea..dfa3d15df 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,8 +4,6 @@ include INSTALL include LICENSE include MANIFEST.in include scrapy/mime.types -include scrapyd/default_scrapyd.conf -recursive-include scrapyd/tests *.egg recursive-include scrapy/templates * recursive-include scrapy/tests/sample_data * recursive-include scrapy license.txt diff --git a/Makefile.buildbot b/Makefile.buildbot index 61e40b2b0..611260b2a 100644 --- a/Makefile.buildbot +++ b/Makefile.buildbot @@ -1,8 +1,18 @@ TRIAL := $(shell which trial) +BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +ifeq ($(BRANCH),master) +export SCRAPY_VERSION_FROM_GIT=1 +endif +export PYTHONPATH=$(PWD) -deb: +test: + coverage run --branch $(TRIAL) --reporter=text scrapy.tests + rm -rf htmlcov && coverage html + -s3cmd sync -P htmlcov/ s3://static.scrapy.org/coverage-scrapy-$(BRANCH)/ + +build: python extras/makedeb.py build -deb-clean: - debclean - python extras/makedeb.py clean +clean: + git checkout debian scrapy/__init__.py + git clean -dfq diff --git a/bin/runtests.sh b/bin/runtests.sh index 0f6a309f7..0e7a318b9 100755 --- a/bin/runtests.sh +++ b/bin/runtests.sh @@ -37,7 +37,7 @@ fi find . -name '*.py[co]' -delete if [ $# -eq 0 ]; then - $trial --reporter=text scrapy scrapyd + $trial --reporter=text scrapy else $trial "$@" fi diff --git a/bin/scrapyd b/bin/scrapyd deleted file mode 100755 index fe440cbb5..000000000 --- a/bin/scrapyd +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -repotac=$(cd $(dirname $0)/../extras; pwd)/scrapyd.tac - -if [ -f "$repotac" ]; then - tacfile="$repotac" -elif [ -f "/usr/share/scrapyd/scrapyd.tac" ]; then - tacfile="/usr/share/scrapyd/scrapyd.tac" -else - echo "Unable to find scrapy.tac file" - exit 1 -fi - -twistd -ny "$tacfile" diff --git a/debian/control b/debian/control index 43d48859f..fcf2b5b93 100644 --- a/debian/control +++ b/debian/control @@ -17,14 +17,3 @@ Description: Python web crawling and scraping framework used to crawl websites and extract structured data from their pages. It can be used for a wide range of purposes, from data mining to monitoring and automated testing. - -Package: scrapyd-SUFFIX -Architecture: all -Depends: scrapy-SUFFIX (>= ${source:Version}), python-setuptools -Conflicts: scrapyd, scrapyd-0.11 -Provides: scrapyd -Description: Scrapy Service - The Scrapy service allows you to deploy your Scrapy projects by building - Python eggs of them and uploading them to the Scrapy service using a JSON API - that you can also use for scheduling spider runs. It supports multiple - projects also. diff --git a/debian/rules b/debian/rules index 3026acd0e..b8796e6e3 100755 --- a/debian/rules +++ b/debian/rules @@ -3,6 +3,3 @@ %: dh $@ - -override_dh_installinit: - dh_installinit --name scrapyd diff --git a/debian/scrapy.install b/debian/scrapy.install index 2ccb5ce19..5977d5f43 100644 --- a/debian/scrapy.install +++ b/debian/scrapy.install @@ -1,3 +1 @@ -usr/lib/python*/*-packages/scrapy* -usr/bin extras/scrapy_bash_completion etc/bash_completion.d/ diff --git a/debian/scrapyd-files/000-default b/debian/scrapyd-files/000-default deleted file mode 100644 index e3afc8f54..000000000 --- a/debian/scrapyd-files/000-default +++ /dev/null @@ -1,8 +0,0 @@ -[scrapyd] -http_port = 6800 -debug = off -#max_proc = 1 -eggs_dir = /var/lib/scrapyd/eggs -dbs_dir = /var/lib/scrapyd/dbs -items_dir = /var/lib/scrapyd/items -logs_dir = /var/log/scrapyd diff --git a/debian/scrapyd.default b/debian/scrapyd.default deleted file mode 100644 index f71fdb569..000000000 --- a/debian/scrapyd.default +++ /dev/null @@ -1 +0,0 @@ -# Defaults for Scrapy service diff --git a/debian/scrapyd.dirs b/debian/scrapyd.dirs deleted file mode 100644 index 31ae26fdb..000000000 --- a/debian/scrapyd.dirs +++ /dev/null @@ -1,5 +0,0 @@ -var/lib/scrapyd -var/lib/scrapyd/eggs -var/lib/scrapyd/dbs -var/lib/scrapyd/items -var/log/scrapyd diff --git a/debian/scrapyd.install b/debian/scrapyd.install deleted file mode 100644 index f46d4e3bd..000000000 --- a/debian/scrapyd.install +++ /dev/null @@ -1,2 +0,0 @@ -debian/scrapyd-files/000-default etc/scrapyd/conf.d -extras/scrapyd.tac usr/share/scrapyd diff --git a/debian/scrapyd.lintian-overrides b/debian/scrapyd.lintian-overrides deleted file mode 100644 index 52f5e4cb7..000000000 --- a/debian/scrapyd.lintian-overrides +++ /dev/null @@ -1,2 +0,0 @@ -new-package-should-close-itp-bug -script-in-etc-init.d-not-registered-via-update-rc.d /etc/init.d/scrapyd diff --git a/debian/scrapyd.postinst b/debian/scrapyd.postinst deleted file mode 100644 index db0ba9589..000000000 --- a/debian/scrapyd.postinst +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -set -e - -case "$1" in - configure) - # Create user to run the service as - if [ -z "`id -u scrapy 2> /dev/null`" ]; then - adduser --system --home /var/lib/scrapyd --gecos "scrapy" \ - --no-create-home --disabled-password \ - --quiet scrapy || true - fi - - chown scrapy:nogroup /var/log/scrapyd \ - /var/lib/scrapyd /var/lib/scrapyd/eggs /var/lib/scrapyd/dbs \ - /var/lib/scrapyd/items - - update-python-modules -p # so upstart restart uses the new code - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -#DEBHELPER# - -exit 0 - - diff --git a/debian/scrapyd.postrm b/debian/scrapyd.postrm deleted file mode 100644 index 5f114be46..000000000 --- a/debian/scrapyd.postrm +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -e - -if [ purge = "$1" ]; then - if [ -x "$(command -v deluser)" ]; then - deluser --quiet --system scrapy > /dev/null || true - else - echo >&2 "not removing scrapy system account because deluser command was not found" - fi -fi - -#DEBHELPER# - -exit 0 - - diff --git a/debian/scrapyd.scrapyd.upstart b/debian/scrapyd.scrapyd.upstart deleted file mode 100644 index 5a53d7086..000000000 --- a/debian/scrapyd.scrapyd.upstart +++ /dev/null @@ -1,13 +0,0 @@ -# Scrapy service - -start on runlevel [2345] -stop on runlevel [06] - -script - [ -r /etc/default/scrapyd ] && . /etc/default/scrapyd - logdir=/var/log/scrapyd - exec twistd -ny /usr/share/scrapyd/scrapyd.tac \ - -u scrapy -g nogroup \ - --pidfile /var/run/scrapyd.pid \ - -l $logdir/scrapyd.log >$logdir/scrapyd.out 2>$logdir/scrapyd.err -end script diff --git a/docs/topics/commands.rst b/docs/topics/commands.rst index c4941da08..bb95720a7 100644 --- a/docs/topics/commands.rst +++ b/docs/topics/commands.rst @@ -249,24 +249,6 @@ Usage examples:: [FAILED] first_spider:parse >>> Returned 92 requests, expected 0..4 -.. command:: server - -server ------- - -* Syntax: ``scrapy server`` -* Requires project: *yes* - -Start Scrapyd server for this project, which can be referred from the JSON API -with the project name ``default``. For more info see: :ref:`topics-scrapyd`. - -Usage example:: - - $ scrapy server - [ ... scrapyd starts and stays idle waiting for spiders to get scheduled ... ] - -To schedule spiders, use the Scrapyd JSON API. - .. command:: list list diff --git a/extras/makedeb.py b/extras/makedeb.py index 08a02645f..14ed4dcd6 100644 --- a/extras/makedeb.py +++ b/extras/makedeb.py @@ -2,7 +2,7 @@ import sys, os, glob, shutil from subprocess import check_call def build(suffix): - for ifn in glob.glob("debian/scrapy.*") + glob.glob("debian/scrapyd.*"): + for ifn in glob.glob("debian/scrapy.*"): s = open(ifn).read() s = s.replace('SUFFIX', suffix) pre, suf = ifn.split('.', 1) @@ -21,8 +21,7 @@ def build(suffix): check_call('debuild -us -uc -b', shell=True) def clean(suffix): - for f in glob.glob("debian/python-scrapy%s*" % suffix) + \ - glob.glob("debian/scrapyd%s*" % suffix): + for f in glob.glob("debian/python-scrapy%s*" % suffix): if os.path.isdir(f): shutil.rmtree(f) else: diff --git a/extras/scrapyd.tac b/extras/scrapyd.tac deleted file mode 100644 index 6abce3086..000000000 --- a/extras/scrapyd.tac +++ /dev/null @@ -1,2 +0,0 @@ -from scrapyd import get_application -application = get_application() diff --git a/extras/test-scrapyd.sh b/extras/test-scrapyd.sh deleted file mode 100755 index 5e9080250..000000000 --- a/extras/test-scrapyd.sh +++ /dev/null @@ -1,122 +0,0 @@ -#!/bin/bash -# -# This script is a quick system test for Scrapyd that: -# -# 1. runs scrapyd -# 2. creates a new project and deploys it on scrapyd -# 3. schedules a spider on scrapyd and waits for it to finish -# 4. check the spider scraped the expected data -# - -set -e - -export PATH=$PATH:$(pwd)/bin -export PYTHONPATH=$PYTHONPATH:$(pwd) - -scrapyd_dir=$(mktemp /tmp/test-scrapyd.XXXXXXX -d) -scrapyd_log=$scrapyd_dir/scrapyd.log -scrapy_dir=$(mktemp /tmp/test-scrapy.XXXXXXX -d) - -echo "scrapyd dir: $scrapyd_dir" -echo "scrapy dir : $scrapy_dir" - -twistd -ny extras/scrapyd.tac -d $scrapyd_dir -l $scrapyd_log & - -cd $scrapy_dir -scrapy startproject testproj -cd testproj -cat > testproj/spiders/insophia.py < scrapy.cfg < -Scrapyd - -

Scrapyd

-

Available projects: %(projects)s

- - -

How to schedule a spider?

- -

To schedule a spider you need to use the API (this web UI is only for -monitoring)

- -

Example using curl:

-

curl http://localhost:6800/schedule.json -d project=default -d spider=somespider

- -

For more information about the API, see the Scrapyd documentation

- - -""" % vars - - -class Jobs(resource.Resource): - - def __init__(self, root): - resource.Resource.__init__(self) - self.root = root - - def render(self, txrequest): - s = "Scrapyd" - s += "" - s += "

Jobs

" - s += "

Go back

" - s += "" - s += "" - s += "" - for project, queue in self.root.poller.queues.items(): - for m in queue.list(): - s += "" - s += "" % project - s += "" % str(m['name']) - s += "" % str(m['_job']) - s += "" - s += "" - for p in self.root.launcher.processes.values(): - s += "" - for a in ['project', 'spider', 'job', 'pid']: - s += "" % getattr(p, a) - s += "" % (datetime.now() - p.start_time) - s += "" % (p.project, p.spider, p.job) - s += "" % (p.project, p.spider, p.job) - s += "" - s += "" - for p in self.root.launcher.finished: - s += "" - for a in ['project', 'spider', 'job']: - s += "" % getattr(p, a) - s += "" - s += "" % (p.end_time - p.start_time) - s += "" % (p.project, p.spider, p.job) - s += "" % (p.project, p.spider, p.job) - s += "" - s += "
ProjectSpiderJobPIDRuntimeLogItems
Pending
%s%s%s
Running
%s%sLogItems
Finished
%s%sLogItems
" - s += "" - s += "" - return s diff --git a/setup.py b/setup.py index 551bb5208..1c2a610d8 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# Scrapy setup.py script +# Scrapy setup.py script # # It doesn't depend on setuptools, but if setuptools is available it'll use # some of its features, like package dependencies. @@ -57,7 +57,7 @@ if root_dir != '': def is_not_module(filename): return os.path.splitext(f)[1] not in ['.py', '.pyc', '.pyo'] -for scrapy_dir in ['scrapy', 'scrapyd']: +for scrapy_dir in ['scrapy']: for dirpath, dirnames, filenames in os.walk(scrapy_dir): # Ignore dirnames that start with '.' for i, dirname in enumerate(dirnames): @@ -121,5 +121,5 @@ except ImportError: from distutils.core import setup else: setup_args['install_requires'] = ['Twisted>=8.0', 'w3lib>=1.2', 'lxml', 'pyOpenSSL'] - + setup(**setup_args) diff --git a/tox.ini b/tox.ini index e563fb3c7..157c0c217 100644 --- a/tox.ini +++ b/tox.ini @@ -9,4 +9,4 @@ envlist = py26, py27 [testenv] commands = pip install --use-mirrors -r .travis/requirements-latest.txt - trial scrapy scrapyd + trial scrapy