Skip to content

Commit b0c18c5

Browse files
authored
Merge pull request #17 from openzim/fix_execute_after
Fix `execute_after` issues
2 parents ce2d39f + 6cb4dd2 commit b0c18c5

File tree

7 files changed

+31
-30
lines changed

7 files changed

+31
-30
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ repos:
77
- id: trailing-whitespace
88
- id: end-of-file-fixer
99
- repo: https://github.com/psf/black
10-
rev: "24.2.0"
10+
rev: "24.4.2"
1111
hooks:
1212
- id: black
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.2.1
14+
rev: v0.4.3
1515
hooks:
1616
- id: ruff
1717
- repo: https://github.com/RobertCraigie/pyright-python
18-
rev: v1.1.350
18+
rev: v1.1.361
1919
hooks:
2020
- id: pyright
2121
name: pyright (system)

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Indentation of `execute_after` logs is too deep #15
13+
14+
### Changed
15+
16+
- `execute_after` does not display detailled logs of stuff run #16
17+
1018
## [0.2.0] - 2024-02-16
1119

1220
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This plugin intentionally has few dependencies, using the Python standard librar
1515

1616
hatch-openzim adheres to openZIM's [Contribution Guidelines](https://github.com/openzim/overview/wiki/Contributing).
1717

18-
hatch-openzim has implemented openZIM's [Python bootstrap, conventions and policies](https://github.com/openzim/_python-bootstrap/docs/Policy.md) **v1.0.0**.
18+
hatch-openzim has implemented openZIM's [Python bootstrap, conventions and policies](https://github.com/openzim/_python-bootstrap/blob/main/docs/Policy.md) **v1.0.1**.
1919

2020
## Quick start
2121

pyproject.toml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,36 @@ name = "hatch-openzim"
77
requires-python = ">=3.8,<3.13"
88
description = "openZIM hatch plugin to set metadata automatically and download files at build time"
99
readme = "README.md"
10-
classifiers = [ # needs hatch-openzim 0.2.0 to make it dynamic with additional-classifiers
11-
"Framework :: Hatch",
12-
"Programming Language :: Python :: 3",
13-
"Programming Language :: Python :: 3.8",
14-
"Programming Language :: Python :: 3.9",
15-
"Programming Language :: Python :: 3.10",
16-
"Programming Language :: Python :: 3.11",
17-
"Programming Language :: Python :: 3.12",
18-
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
19-
]
2010
dependencies = [
2111
"hatchling==1.21.1",
2212
"packaging==23.2",
2313
"toml==0.10.2", # to be removed once only 3.11 and above is supported
2414
]
25-
dynamic = ["authors", "keywords", "license", "version", "urls"]
15+
dynamic = ["authors", "keywords", "license", "version", "urls", "classifiers"]
2616

2717
[tool.hatch.metadata.hooks.openzim-metadata]
2818
additional-keywords = ["hatch","plugin","download","file"]
29-
preserve-classifiers = true # to be removed once 0.2.0 is used
19+
additional-classifiers = [
20+
"Framework :: Hatch",
21+
]
3022

3123
[project.optional-dependencies]
3224
scripts = [
3325
"invoke==2.2.0",
3426
]
3527
lint = [
36-
"black==24.2.0",
37-
"ruff==0.2.1",
28+
"black==24.4.2",
29+
"ruff==0.4.3",
3830
]
3931
check = [
40-
"pyright==1.1.350",
32+
"pyright==1.1.361",
4133
]
4234
test = [
43-
"pytest==8.0.0",
44-
"coverage==7.4.1",
35+
"pytest==8.2.0",
36+
"coverage==7.5.1",
4537
]
4638
dev = [
47-
"pre-commit==3.6.1",
39+
"pre-commit==3.7.0",
4840
"debugpy==1.8.1",
4941
"hatch-openzim[scripts]",
5042
"hatch-openzim[lint]",

src/hatch_openzim/files_install.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,19 @@ def _process_execute_after(base_target_dir: Path, actions: List[str]):
109109
"""execute actions after file(s) installation"""
110110

111111
for action in actions:
112-
logger.info(f" Executing '{action}'")
113-
process = subprocess.run(
112+
logger.info(f" Executing '{action}'")
113+
process = subprocess.run( # noqa: PLW1510
114114
action,
115115
shell=True, # noqa: S602 # nosec: B602
116116
cwd=base_target_dir,
117117
text=True,
118-
check=True,
119-
capture_output=True,
118+
stderr=subprocess.STDOUT,
119+
stdout=subprocess.PIPE,
120120
)
121121
if process.stdout:
122-
logger.info(f" stdout:\n{process.stdout}")
122+
logger.info(f" stdout/stderr:\n{process.stdout}")
123+
if process.returncode:
124+
raise Exception("execute_after command failed, see logs above for details.")
123125

124126

125127
def _process_get_file_action(

tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def fix_black(ctx: Context, args: str = "."):
9292
def fix_ruff(ctx: Context, args: str = "."):
9393
"""fix all ruff rules"""
9494
args = args or "." # needed for hatch script
95-
ctx.run(f"ruff --fix {args}", pty=use_pty)
95+
ctx.run(f"ruff check --fix {args}", pty=use_pty)
9696

9797

9898
@task(

tests/test_files_install.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import subprocess
32
import tempfile
43
from pathlib import Path
54
from typing import List
@@ -212,7 +211,7 @@ def test_execute_after_failure():
212211
os.chdir(temp_dir)
213212

214213
with pytest.raises(
215-
subprocess.CalledProcessError,
214+
Exception, match="execute_after command failed, see logs above for details."
216215
):
217216
files_install.process(
218217
str(

0 commit comments

Comments
 (0)