/usr/share/pyshared/scrapyd/interfaces.py is in python-scrapy 0.14.4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | from zope.interface import Interface
class IEggStorage(Interface):
"""A component that handles storing and retrieving eggs"""
def put(eggfile, project, version):
"""Store the egg (passed in the file object) under the given project and
version"""
def get(project, version=None):
"""Return a tuple (version, file) with the the egg for the specified
project and version. If version is None, the latest version is
returned. If no egg is found for the given project/version (None, None)
should be returned."""
def list(project):
"""Return the list of versions which have eggs stored (for the given
project) in order (the latest version is the currently used)."""
def delete(project, version=None):
"""Delete the egg stored for the given project and version. If should
also delete the project if no versions are left"""
class IPoller(Interface):
"""A component that polls for projects that need to run"""
def poll():
"""Called periodically to poll for projects"""
def next():
"""Return the next message.
It should return a Deferred which will get fired when there is a new
project that needs to run, or already fired if there was a project
waiting to run already.
The message is a dict containing (at least):
* the name of the project to be run in the '_project' key
* the name of the spider to be run in the '_spider' key
* a unique identifier for this run in the `_job` key
This message will be passed later to IEnvironment.get_environment().
"""
def update_projects():
"""Called when projects may have changed, to refresh the available
projects"""
class ISpiderQueue(Interface):
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"""
def schedule(project, spider_name, **spider_args):
"""Schedule a spider for the given project"""
def list_projects():
"""Return the list of available projects"""
def update_projects():
"""Called when projects may have changed, to refresh the available
projects"""
class IEnvironment(Interface):
"""A component to generate the environment of crawler processes"""
def get_environment(message, slot):
"""Return the environment variables to use for running the process.
`message` is the message received from the IPoller.next() method
`slot` is the Launcher slot where the process will be running.
"""
|