Skip to content

Commit

Permalink
Merge pull request #17 from openzim/fix_execute_after
Browse files Browse the repository at this point in the history
Fix `execute_after` issues
  • Loading branch information
benoit74 authored May 6, 2024
2 parents ce2d39f + 6cb4dd2 commit b0c18c5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: "24.2.0"
rev: "24.4.2"
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
rev: v0.4.3
hooks:
- id: ruff
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.350
rev: v1.1.361
hooks:
- id: pyright
name: pyright (system)
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Indentation of `execute_after` logs is too deep #15

### Changed

- `execute_after` does not display detailled logs of stuff run #16

## [0.2.0] - 2024-02-16

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This plugin intentionally has few dependencies, using the Python standard librar

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

hatch-openzim has implemented openZIM's [Python bootstrap, conventions and policies](https://github.com/openzim/_python-bootstrap/docs/Policy.md) **v1.0.0**.
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**.

## Quick start

Expand Down
28 changes: 10 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,36 @@ name = "hatch-openzim"
requires-python = ">=3.8,<3.13"
description = "openZIM hatch plugin to set metadata automatically and download files at build time"
readme = "README.md"
classifiers = [ # needs hatch-openzim 0.2.0 to make it dynamic with additional-classifiers
"Framework :: Hatch",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
]
dependencies = [
"hatchling==1.21.1",
"packaging==23.2",
"toml==0.10.2", # to be removed once only 3.11 and above is supported
]
dynamic = ["authors", "keywords", "license", "version", "urls"]
dynamic = ["authors", "keywords", "license", "version", "urls", "classifiers"]

[tool.hatch.metadata.hooks.openzim-metadata]
additional-keywords = ["hatch","plugin","download","file"]
preserve-classifiers = true # to be removed once 0.2.0 is used
additional-classifiers = [
"Framework :: Hatch",
]

[project.optional-dependencies]
scripts = [
"invoke==2.2.0",
]
lint = [
"black==24.2.0",
"ruff==0.2.1",
"black==24.4.2",
"ruff==0.4.3",
]
check = [
"pyright==1.1.350",
"pyright==1.1.361",
]
test = [
"pytest==8.0.0",
"coverage==7.4.1",
"pytest==8.2.0",
"coverage==7.5.1",
]
dev = [
"pre-commit==3.6.1",
"pre-commit==3.7.0",
"debugpy==1.8.1",
"hatch-openzim[scripts]",
"hatch-openzim[lint]",
Expand Down
12 changes: 7 additions & 5 deletions src/hatch_openzim/files_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,17 +109,19 @@ def _process_execute_after(base_target_dir: Path, actions: List[str]):
"""execute actions after file(s) installation"""

for action in actions:
logger.info(f" Executing '{action}'")
process = subprocess.run(
logger.info(f" Executing '{action}'")
process = subprocess.run( # noqa: PLW1510
action,
shell=True, # noqa: S602 # nosec: B602
cwd=base_target_dir,
text=True,
check=True,
capture_output=True,
stderr=subprocess.STDOUT,
stdout=subprocess.PIPE,
)
if process.stdout:
logger.info(f" stdout:\n{process.stdout}")
logger.info(f" stdout/stderr:\n{process.stdout}")
if process.returncode:
raise Exception("execute_after command failed, see logs above for details.")


def _process_get_file_action(
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def fix_black(ctx: Context, args: str = "."):
def fix_ruff(ctx: Context, args: str = "."):
"""fix all ruff rules"""
args = args or "." # needed for hatch script
ctx.run(f"ruff --fix {args}", pty=use_pty)
ctx.run(f"ruff check --fix {args}", pty=use_pty)


@task(
Expand Down
3 changes: 1 addition & 2 deletions tests/test_files_install.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import subprocess
import tempfile
from pathlib import Path
from typing import List
Expand Down Expand Up @@ -212,7 +211,7 @@ def test_execute_after_failure():
os.chdir(temp_dir)

with pytest.raises(
subprocess.CalledProcessError,
Exception, match="execute_after command failed, see logs above for details."
):
files_install.process(
str(
Expand Down

0 comments on commit b0c18c5

Please sign in to comment.