Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: switch project to src-layout #474

Merged
merged 3 commits into from
Nov 19, 2024
Merged
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
10 changes: 5 additions & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
include loki/py.typed
include grizzly/common/harness.html
include grizzly/common/post_launch_delay.html
include grizzly/py.typed
include sapphire/py.typed
include src/loki/py.typed
include src/grizzly/common/harness.html
include src/grizzly/common/post_launch_delay.html
include src/grizzly/py.typed
include src/sapphire/py.typed
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ install_requires =
lithium-reducer >= 3.0.0
prefpicker >= 1.23.0
psutil >= 5.9.4
package_dir =
= src
packages =
grizzly
grizzly.adapter
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions grizzly/common/report.py → src/grizzly/common/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,5 +474,4 @@ def tail(in_file: Path, size_limit: int) -> None:
out_fp.write(b"[LOG TAILED]\n")
copyfileobj(in_fp, out_fp, 0x10000) # 64KB chunks
in_file.unlink()
# Python 3.9+: move() accepts a path-like object for both src and dst
move(out_file, str(in_file.resolve()))
move(out_file, in_file)
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def _submit_report(
log_path = dest / f"{self.report_prefix}_logs"
if log_path.is_dir():
LOG.warning("Report log path exists '%s'", log_path)
# Python 3.9+: move() accepts a path-like object for both src and dst
move(str(report.path.resolve()), str(log_path.resolve()))
move(report.path, log_path)
# avoid filling the disk
free_space = disk_usage(str(log_path.resolve())).free
if free_space < self.min_space:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions grizzly/common/storage.py → src/grizzly/common/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def __init__(
self.env_vars: dict[str, str] = {}
self.hang = False
self.https = False
self.input_fname = input_fname # file that was used to create the test case
# file that was used to create the test case
self.input_fname = input_fname
self.entry_point = self.sanitize_path(entry_point)
self.timestamp = time() if timestamp is None else timestamp
self.version = GRZ_VERSION
Expand Down Expand Up @@ -208,8 +209,7 @@ def add_from_file(
if copy:
copyfile(src_file, dst_file)
else:
# Python 3.9+: move() accepts a path-like object for both src and dst
move(str(src_file.resolve()), str(dst_file.resolve()))
move(src_file, dst_file)

# entry_point is always 'required'
if required or url_path == self.entry_point:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions grizzly/target/assets.py → src/grizzly/target/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ def add(self, asset: str, path: Path, copy: bool = True) -> Path:
else:
copytree(path, dst)
else:
# Python 3.9+: move() accepts a path-like object for both src and dst
move(str(path.resolve()), str(self.path.resolve()))
move(path, self.path)
self.assets[asset] = path.name
LOG.debug("%s asset %r to '%s'", "copied" if copy else "moved", asset, dst)
return dst
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions sapphire/test_worker.py → src/sapphire/test_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,18 @@ def test_response_01(req, method, scheme, path):
@mark.parametrize(
"req",
[
b"",
b"a",
# Invalid IPv6 URL
b"GET http://[test/ HTTP/1.1",
# Missing Path
b"GET HTTP/1.1",
# Invalid Path
b"GET a a a a a HTTP/1.1",
# Invalid characters under NFKC normalization
b"GET http://%E2%84%80/ HTTP/1.1",
# Missing method
b" / HTTP/1.1",
],
)
def test_response_02(req):
Expand Down
7 changes: 3 additions & 4 deletions sapphire/worker.py → src/sapphire/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,17 @@ def parse(cls, raw_data: bytes) -> Request | None:

# TODO: parse headers if needed

raw_url = req_match.group("url")
try:
url_str = req_match.group("url").decode("ascii", errors="replace")
# unquote() accepts str | bytes as of Python 3.9
url = urlparse(unquote(url_str))
url = urlparse(unquote(raw_url))
except ValueError as exc:
msg = str(exc)
if (
"contains invalid characters under NFKC normalization" not in msg
and "Invalid IPv6 URL" not in msg
and "does not appear to be an IPv4 or IPv6 address" not in msg
):
LOG.error("Failed to parse URL: %r", url_str)
LOG.error("Failed to parse URL: %r", raw_url)
raise
LOG.debug("failed to parse url from request")
return None
Expand Down
Loading