moved spider queues to scrapyd

--HG--
rename : scrapy/spiderqueue.py => scrapyd/spiderqueue.py
rename : scrapy/tests/test_spiderqueue.py => scrapyd/tests/test_spiderqueue.py
This commit is contained in:
Pablo Hoffman 2011-07-19 19:39:27 -03:00
parent d97d6d20c6
commit 75e2c3eb33
6 changed files with 39 additions and 40 deletions

View File

@ -1,39 +1,5 @@
from zope.interface import Interface
class ISpiderQueue(Interface):
def from_settings(settings):
"""Class method to instantiate from settings"""
def add(name, **spider_args):
"""Add a spider to the queue given its name a some spider arguments.
This method can return a deferred. """
def pop():
"""Pop the next mesasge from the queue. The messages is a dict
conaining a key 'name' with the spider name and other keys as spider
attributes.
This method can return a deferred. """
def list():
"""Return a list with the messages in the queue. Each message is a dict
which must have a 'name' key (with the spider name), and other optional
keys that will be used as spider arguments, to create the spider.
This method can return a deferred. """
def count():
"""Return the number of spiders in the queue.
This method can return a deferred. """
def clear():
"""Clear the queue.
This method can return a deferred. """
class ISpiderManager(Interface):
def from_settings(settings):

View File

@ -237,8 +237,6 @@ SPIDER_MIDDLEWARES_BASE = {
SPIDER_MODULES = []
SPIDER_QUEUE_CLASS = 'scrapy.spiderqueue.SqliteSpiderQueue'
SPIDER_CONTEXT_ENABLED = True
SPIDER_CONTEXT_STORAGE_CLASS = 'scrapy.contrib.spidercontext.SqliteSpiderContextStorage'

View File

@ -47,6 +47,41 @@ class IPoller(Interface):
projects"""
class ISpiderQueue(Interface):
def from_settings(settings):
"""Class method to instantiate from settings"""
def add(name, **spider_args):
"""Add a spider to the queue given its name a some spider arguments.
This method can return a deferred. """
def pop():
"""Pop the next mesasge from the queue. The messages is a dict
conaining a key 'name' with the spider name and other keys as spider
attributes.
This method can return a deferred. """
def list():
"""Return a list with the messages in the queue. Each message is a dict
which must have a 'name' key (with the spider name), and other optional
keys that will be used as spider arguments, to create the spider.
This method can return a deferred. """
def count():
"""Return the number of spiders in the queue.
This method can return a deferred. """
def clear():
"""Clear the queue.
This method can return a deferred. """
class ISpiderScheduler(Interface):
"""A component to schedule spider runs"""

View File

@ -1,6 +1,6 @@
from zope.interface import implements
from scrapy.interfaces import ISpiderQueue
from scrapyd.interfaces import ISpiderQueue
from scrapy.utils.sqlite import JsonSqlitePriorityQueue
from scrapy.utils.project import sqlite_db

View File

@ -3,8 +3,8 @@ from twisted.trial import unittest
from zope.interface.verify import verifyObject
from scrapy.interfaces import ISpiderQueue
from scrapy.spiderqueue import SqliteSpiderQueue
from scrapyd.interfaces import ISpiderQueue
from scrapyd.spiderqueue import SqliteSpiderQueue
class SpiderQueueTest(unittest.TestCase):
"""This test case can be used easily for testing other SpiderQueue's by

View File

@ -3,7 +3,7 @@ import os
from subprocess import Popen, PIPE
from ConfigParser import NoSectionError
from scrapy.spiderqueue import SqliteSpiderQueue
from scrapyd.spiderqueue import SqliteSpiderQueue
from scrapy.utils.python import stringify_dict, unicode_to_str
from scrapyd.config import Config