Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion scrapyd_api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
LIST_VERSIONS_ENDPOINT = 'list_versions'
SCHEDULE_ENDPOINT = 'schedule'
DAEMON_STATUS_ENDPOINT = 'daemonstatus'
# status.json endpoint added in 1.5.0
# Get the status of a job
STATUS_ENDPOINT = 'status'

DEFAULT_ENDPOINTS = {
ADD_VERSION_ENDPOINT: '/addversion.json',
Expand All @@ -21,7 +24,10 @@
LIST_SPIDERS_ENDPOINT: '/listspiders.json',
LIST_VERSIONS_ENDPOINT: '/listversions.json',
SCHEDULE_ENDPOINT: '/schedule.json',
DAEMON_STATUS_ENDPOINT: '/daemonstatus.json'
DAEMON_STATUS_ENDPOINT: '/daemonstatus.json',
# status.json endpoint added in 1.5.0
# Get the status of a job
STATUS_ENDPOINT: 'status.json'
}

FINISHED = 'finished'
Expand Down
12 changes: 12 additions & 0 deletions scrapyd_api/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,15 @@ def daemon_status(self):
url = self._build_url(constants.DAEMON_STATUS_ENDPOINT)
json = self.client.get(url, timeout=self.timeout)
return json

def status(self, job):
"""
Added in Scrapyd version 1.5.0.
Get the status of a job.
First class, maps to Scrapyd's status job endpoint.
"""
url = self._build_url(constants.STATUS_ENDPOINT)
params = {'job': job}
json = self.client.get(url, params=params, timeout=self.timeout)
return json['currstate']