diff --git a/docs/news.rst b/docs/news.rst index 77702c43..830f4bb9 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -60,13 +60,14 @@ CLI Utils ^^^^^ -Move functions from ``scrapyd.utils`` into their callers: +- Move functions from ``scrapyd.utils`` into their callers: -- ``sorted_versions`` to ``scrapyd.eggstorage`` -- ``get_crawl_args`` to ``scrapyd.launcher`` -- ``JsonResource``, ``get_spider_list`` and ``UtilsCache`` to ``scrapyd.webservice`` + - ``sorted_versions`` to ``scrapyd.eggstorage`` + - ``get_crawl_args`` to ``scrapyd.launcher`` + - ``JsonResource``, ``get_spider_list`` and ``UtilsCache`` to ``scrapyd.webservice`` -Move ``activate_egg`` from ``scrapyd.eggutils`` to ``scrapyd.runner`` +- Move ``activate_egg`` from ``scrapyd.eggutils`` to its caller, ``scrapyd.runner``. +- Move ``job_items_url`` and ``job_log_url`` from ``scrapyd.jobstorage`` to ``scrapyd.utils``. :ref:`jobstorage` is not responsible for URLs. Fixed ~~~~~ diff --git a/scrapyd/jobstorage.py b/scrapyd/jobstorage.py index fcb92e87..182163c2 100644 --- a/scrapyd/jobstorage.py +++ b/scrapyd/jobstorage.py @@ -7,14 +7,6 @@ from scrapyd.utils import sqlite_connection_string -def job_log_url(job): - return f"/logs/{job.project}/{job.spider}/{job.job}.log" - - -def job_items_url(job): - return f"/items/{job.project}/{job.spider}/{job.job}.jl" - - class Job: def __init__(self, project, spider, job=None, start_time=None, end_time=None): self.project = project diff --git a/scrapyd/utils.py b/scrapyd/utils.py index e3486ba4..23ab0009 100644 --- a/scrapyd/utils.py +++ b/scrapyd/utils.py @@ -4,6 +4,14 @@ from scrapy.utils.misc import load_object +def job_log_url(job): + return f"/logs/{job.project}/{job.spider}/{job.job}.log" + + +def job_items_url(job): + return f"/items/{job.project}/{job.spider}/{job.job}.jl" + + def get_spider_queues(config): """Return a dict of Spider Queues keyed by project name""" spiderqueue_path = config.get("spiderqueue", "scrapyd.spiderqueue.SqliteSpiderQueue") diff --git a/scrapyd/webservice.py b/scrapyd/webservice.py index 1a5eb505..41863155 100644 --- a/scrapyd/webservice.py +++ b/scrapyd/webservice.py @@ -17,9 +17,8 @@ from scrapyd.config import Config from scrapyd.exceptions import EggNotFoundError, ProjectNotFoundError, RunnerError -from scrapyd.jobstorage import job_items_url, job_log_url from scrapyd.sqlite import JsonSqliteDict -from scrapyd.utils import native_stringify_dict +from scrapyd.utils import job_items_url, job_log_url, native_stringify_dict def param( diff --git a/scrapyd/website.py b/scrapyd/website.py index d26f3b4e..91841dbe 100644 --- a/scrapyd/website.py +++ b/scrapyd/website.py @@ -9,7 +9,7 @@ from twisted.web import resource, static from scrapyd.interfaces import IEggStorage, IPoller, ISpiderScheduler -from scrapyd.jobstorage import job_items_url, job_log_url +from scrapyd.utils import job_items_url, job_log_url class PrefixHeaderMixin: