Skip to content

Commit

Permalink
fix: do not crash if there are no matches
Browse files Browse the repository at this point in the history
  • Loading branch information
isd-project committed Feb 24, 2025
1 parent 8021a51 commit 51d52a2
Show file tree
Hide file tree
Showing 6 changed files with 165 additions and 96 deletions.
42 changes: 42 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
set -euo pipefail

grep "current_version =" "$REPO_ROOT/pyproject.toml"

while true; do
read -rp "Is the current version flag correctly set? [y/N] " yn
case $yn in
[yY]* ) break;;
[Nn]* ) exit;;
* ) exit ;;
esac
done

# update the caches
uv sync
touch "$REPO_ROOT/flake.nix"

# ensure that everything works as expected
mkdocs build --clean
pytest

rm -rf "$REPO_ROOT/dist"
rm -f "$REPO_ROOT/isd.x86_64-linux.AppImage"
rm -f "$REPO_ROOT/isd.aarch64-linux.AppImage"

# start building everything
uv build

echo "Building x86-64 isd-AppImage"
nix build .#isd-AppImage
cp "$(readlink -f ./result)" isd.x86_64-linux.AppImage

echo "Building aarch64 isd-AppImage"
nix build .#packages.aarch64-linux.isd-AppImage
cp "$(readlink -f ./result)" isd.aarch64-linux.AppImage

# publish latest docs
echo "Publishing docs"
mkdocs gh-deploy --no-history

echo "Remember to update PyPI!"

24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,12 @@
# python = pkgs.python313;

# Construct package set
pythonSet311For = eachSystem (
system:
pythonSet311 = (
pkgs:
let
# injecting cairosvg from upstream nixpkgs, as it is currently not
# supported by the uv2nix_hammer project and is still in the todo list.
# https://pyproject-nix.github.io/pyproject.nix/builders/hacks.html
pkgs = pkgsFor.${system};
# python = pkgs.python312;
python = pkgs.python311;
hacks = pkgs.callPackage inputs.pyproject-nix.build.hacks { };
Expand All @@ -117,16 +116,19 @@
prev = prev.cairocffi;
};
})
# (_final: prev: {
# pythonPkgsBuildHost = prev.pythonPkgsBuildHost.overrideScope pyprojectOverrides;
# })
]
)
);
pythonSet313For = eachSystem (
system:
pythonSet313 = (
pkgs:
let
# injecting cairosvg from upstream nixpkgs, as it is currently not
# supported by the uv2nix_hammer project and is still in the todo list.
# https://pyproject-nix.github.io/pyproject.nix/builders/hacks.html
pkgs = pkgsFor.${system};
# pkgs = pkgsFor.${system};
# python = pkgs.python312;
python = pkgs.python313;
hacks = pkgs.callPackage inputs.pyproject-nix.build.hacks { };
Expand Down Expand Up @@ -176,8 +178,10 @@
packages = eachSystem (
system:
let
# https://pyproject-nix.github.io/uv2nix/patterns/cross/index.html
pkgs = pkgsFor.${system};
pythonSet = pythonSet313For.${system};
# pkgs = pkgsFor.${system}.pkgsCross.aarch64-multiplatform;
pythonSet = pythonSet313 pkgs;
version = (builtins.fromTOML (builtins.readFile ./pyproject.toml)).project.version;
gen_unit =
name:
Expand Down Expand Up @@ -330,7 +334,7 @@
system:
let
pkgs = pkgsFor.${system};
pythonSet = pythonSet311For.${system};
pythonSet = pythonSet311 pkgs;
lib = pkgs.lib;
in
{
Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ dependencies = [
"pydantic>=2.10.4",
"types-pyyaml>=6.0.12.20241221",
]
version = "0.5.0"
version = "0.5.1"

# # versioningit was great in theory
# # but it comes with too many issues for packaging
Expand Down Expand Up @@ -62,8 +62,10 @@ docs = [
]

[build-system]
requires = ["hatchling", "editables"]
# requires = ["hatchling", "editables"]
requires = ["hatchling", "editables", "setuptools"]
build-backend = "hatchling.build"
# build-backend = "hatchling.ouroboros"

[project.scripts]
isd = "isd_tui.isd:main"
Expand Down Expand Up @@ -97,7 +99,7 @@ exclude = [
"share/" = "share/"

[tool.bumpversion]
current_version = "0.5.0"
current_version = "0.5.1"
parse = """
(?P<major>0|[1-9]\\d*)\\.
(?P<minor>0|[1-9]\\d*)\\.
Expand Down
12 changes: 8 additions & 4 deletions src/isd_tui/isd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,10 +1319,13 @@ async def load_unit_to_state_dict(mode: str, *pattern: str) -> Dict[str, UnitRep
)
stdout, stderr = await proc.communicate()

# Ignore if there is an issue with ancient `systemd` versions
# that do not have `systemctl list-unit-files` as a sub-command.
if proc.returncode == 0:
parsed_unit_files = parse_list_unit_files_lines(stdout.decode())
# If there are no matches for the selected pattern,
# `systemctl list-unit-files` returns a non-zero exit code!
# Better to check `stderr`.
if stderr.decode() != "":
raise Exception(proc.stderr)

parsed_unit_files = parse_list_unit_files_lines(stdout.decode())
return {**parsed_unit_files, **parsed_units}


Expand Down Expand Up @@ -2525,6 +2528,7 @@ def __init__(
if force_defaults:
self.settings = Settings.model_construct()
self.settings.cache_input = False
self.settings.startup_mode = StartupMode("user")
self.settings_error = None
else:
try:
Expand Down
Loading

0 comments on commit 51d52a2

Please sign in to comment.