Skip to content

Commit 9bc8e85

Browse files
committed
fix: Use target URL, not target name, in URLs
1 parent e671e41 commit 9bc8e85

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

CHANGES.rst

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
History
22
-------
33

4+
2.0.2 (2025-03-08)
5+
~~~~~~~~~~~~~~~~~~
6+
7+
Fixed
8+
^^^^^
9+
10+
- ``scrapyd_client.ScrapyClient`` uses the target's URL instead of the target's name when constructing URLs. (Regression in "``scrapyd-client`` raises an error if no Scrapy project is found, like ``scrapyd-deploy``, instead of assuming a target at ``http://localhost:6800``")
11+
412
2.0.1 (2025-02-12)
513
~~~~~~~~~~~~~~~~~~
614

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "scrapyd-client"
7-
version = "2.0.1"
7+
version = "2.0.2"
88
authors = [{name = "Scrapy developers", email = "[email protected]"}]
99
description = "A client for Scrapyd"
1010
readme = "README.rst"

scrapyd_client/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
def _get_client(args):
1818
target = _get_targets()[args.target]
1919

20-
return ScrapydClient(args.target, target.get("username"), password=target.get("password", ""))
20+
return ScrapydClient(target.get("url"), target.get("username"), password=target.get("password", ""))
2121

2222

2323
def deploy(args): # noqa: ARG001

scrapyd_client/pyclient.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,15 @@
1010

1111
DEFAULT_TARGET_URL = "http://localhost:6800"
1212
HEADERS = requests.utils.default_headers().copy()
13-
HEADERS["User-Agent"] = "Scrapyd-client/2.0.1"
13+
HEADERS["User-Agent"] = "Scrapyd-client/2.0.2"
1414

1515

1616
class ScrapydClient:
1717
"""ScrapydClient to interact with a Scrapyd instance."""
1818

19-
def __init__(
20-
self, url: str = DEFAULT_TARGET_URL, username: str | None = None, password: str | None = None
21-
) -> None:
19+
def __init__(self, url: str | None = None, username: str | None = None, password: str | None = None) -> None:
2220
"""Initialize ScrapydClient."""
23-
self.url = url
21+
self.url = DEFAULT_TARGET_URL if url is None else url
2422
self.auth = get_auth(url=self.url, username=username, password=password)
2523

2624
def projects(self, pattern: str = "*") -> list[str]:

0 commit comments

Comments
 (0)