godotkit 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- godotkit-0.8.1/LICENSE +21 -0
- godotkit-0.8.1/PKG-INFO +78 -0
- godotkit-0.8.1/README.md +61 -0
- godotkit-0.8.1/pyproject.toml +84 -0
- godotkit-0.8.1/pyproject.toml.orig +77 -0
- godotkit-0.8.1/src/godotkit/__init__.py +6 -0
- godotkit-0.8.1/src/godotkit/common/__init__.py +17 -0
- godotkit-0.8.1/src/godotkit/common/core.py +134 -0
- godotkit-0.8.1/src/godotkit/common/git.py +228 -0
- godotkit-0.8.1/src/godotkit/constants.py +11 -0
- godotkit-0.8.1/src/godotkit/engine/__init__.py +24 -0
- godotkit-0.8.1/src/godotkit/engine/engine.py +60 -0
- godotkit-0.8.1/src/godotkit/engine/exceptions.py +6 -0
- godotkit-0.8.1/src/godotkit/engine/release_fetcher.py +424 -0
- godotkit-0.8.1/src/godotkit/engine/utils.py +245 -0
- godotkit-0.8.1/src/godotkit/engine/version_parsing.py +273 -0
- godotkit-0.8.1/src/godotkit/feed/__init__.py +7 -0
- godotkit-0.8.1/src/godotkit/feed/core.py +172 -0
- godotkit-0.8.1/src/godotkit/project/__init__.py +5 -0
- godotkit-0.8.1/src/godotkit/project/parse.py +470 -0
- godotkit-0.8.1/src/godotkit/project/project.py +173 -0
- godotkit-0.8.1/src/godotkit/project/utils.py +65 -0
- godotkit-0.8.1/src/godotkit/py.typed +0 -0
godotkit-0.8.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Killian
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
godotkit-0.8.1/PKG-INFO
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: godotkit
|
|
3
|
+
Version: 0.8.1
|
|
4
|
+
Summary: Python utilities and classes for working with Godot engine releases and projects.
|
|
5
|
+
Author: KROSSEYE
|
|
6
|
+
Author-email: KROSSEYE <30990184+KROSSEYE@users.noreply.github.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: filelock>=4.0,<5.0.0
|
|
10
|
+
Requires-Dist: httpx>=0.28,<1.0.0
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Project-URL: Homepage, https://github.com/krosseye/godotkit
|
|
13
|
+
Project-URL: Documentation, https://krosseye.github.io/godotkit/
|
|
14
|
+
Project-URL: Changelog, https://github.com/krosseye/godotkit/blob/main/CHANGELOG.md
|
|
15
|
+
Project-URL: Issues, https://github.com/krosseye/godotkit/issues
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+

|
|
19
|
+
|
|
20
|
+
[](https://github.com/krosseye/godotkit/actions/workflows/release.yml?query=branch%3Amain)
|
|
21
|
+
[](https://github.com/krosseye/godotkit/releases/latest)
|
|
22
|
+
[](https://github.com/krosseye/godotkit/blob/main/LICENSE)
|
|
23
|
+
[](https://krosseye.github.io/godotkit/)
|
|
24
|
+
|
|
25
|
+
**GodotKit** is a Python library providing functions and classes for the automation of tasks related to [Godot Engine](https://godotengine.org/) releases and projects.
|
|
26
|
+
|
|
27
|
+
It was originally developed to power [GoGo](https://github.com/krosseye/gogo), but is a standalone package that can be used in any Python project requiring programmatic interaction with Godot files and versions.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
Install the latest release from PyPI:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install godotkit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or from the GitHub repository:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install git+https://github.com/krosseye/godotkit.git
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Setup for Developers
|
|
46
|
+
|
|
47
|
+
If you want to contribute to GodotKit, follow these steps to set up your development environment.
|
|
48
|
+
|
|
49
|
+
1. **Clone the Repository**
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/krosseye/godotkit.git
|
|
53
|
+
cd godotkit
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
2. **Install Dependencies**
|
|
57
|
+
|
|
58
|
+
This command installs all dependencies, including those for testing and documentation:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
uv sync --all-extras
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
3. **Install Module in Editable Mode**
|
|
65
|
+
|
|
66
|
+
This ensures that changes you make to the source code are instantly reflected in your environment:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
uv pip install -e .
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
4. **Setup Pre-commit Hooks**
|
|
73
|
+
|
|
74
|
+
Install the pre-commit hooks to automatically run checks before you commit your code:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
uv run prek install
|
|
78
|
+
```
|
godotkit-0.8.1/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[](https://github.com/krosseye/godotkit/actions/workflows/release.yml?query=branch%3Amain)
|
|
4
|
+
[](https://github.com/krosseye/godotkit/releases/latest)
|
|
5
|
+
[](https://github.com/krosseye/godotkit/blob/main/LICENSE)
|
|
6
|
+
[](https://krosseye.github.io/godotkit/)
|
|
7
|
+
|
|
8
|
+
**GodotKit** is a Python library providing functions and classes for the automation of tasks related to [Godot Engine](https://godotengine.org/) releases and projects.
|
|
9
|
+
|
|
10
|
+
It was originally developed to power [GoGo](https://github.com/krosseye/gogo), but is a standalone package that can be used in any Python project requiring programmatic interaction with Godot files and versions.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
Install the latest release from PyPI:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install godotkit
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or from the GitHub repository:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install git+https://github.com/krosseye/godotkit.git
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Setup for Developers
|
|
29
|
+
|
|
30
|
+
If you want to contribute to GodotKit, follow these steps to set up your development environment.
|
|
31
|
+
|
|
32
|
+
1. **Clone the Repository**
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
git clone https://github.com/krosseye/godotkit.git
|
|
36
|
+
cd godotkit
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. **Install Dependencies**
|
|
40
|
+
|
|
41
|
+
This command installs all dependencies, including those for testing and documentation:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
uv sync --all-extras
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
3. **Install Module in Editable Mode**
|
|
48
|
+
|
|
49
|
+
This ensures that changes you make to the source code are instantly reflected in your environment:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
uv pip install -e .
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
4. **Setup Pre-commit Hooks**
|
|
56
|
+
|
|
57
|
+
Install the pre-commit hooks to automatically run checks before you commit your code:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
uv run prek install
|
|
61
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "godotkit"
|
|
3
|
+
version = "0.8.1"
|
|
4
|
+
description = "Python utilities and classes for working with Godot engine releases and projects."
|
|
5
|
+
license = "MIT"
|
|
6
|
+
license-files = ["LICENSE"]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"filelock>=4.0,<5.0.0",
|
|
11
|
+
"httpx>=0.28,<1.0.0",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[[project.authors]]
|
|
15
|
+
name = "KROSSEYE"
|
|
16
|
+
email = "30990184+KROSSEYE@users.noreply.github.com"
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/krosseye/godotkit"
|
|
20
|
+
Documentation = "https://krosseye.github.io/godotkit/"
|
|
21
|
+
Changelog = "https://github.com/krosseye/godotkit/blob/main/CHANGELOG.md"
|
|
22
|
+
Issues = "https://github.com/krosseye/godotkit/issues"
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["uv_build>=0.8.15,<0.14.0"]
|
|
26
|
+
build-backend = "uv_build"
|
|
27
|
+
|
|
28
|
+
[dependency-groups]
|
|
29
|
+
dev = [
|
|
30
|
+
"mkdocs>=1.6.0,<2.0.0",
|
|
31
|
+
"mkdocs-material>=9.8.0,<10.0.0",
|
|
32
|
+
"mkdocstrings[python]>=1.0.0,<2.0.0",
|
|
33
|
+
"mypy>=2.4,<3.0.0",
|
|
34
|
+
"prek>=0.5.0,<1.0.0",
|
|
35
|
+
"pytest>=9.0.0,<10.0.0",
|
|
36
|
+
"pytest-asyncio>=1.4.0",
|
|
37
|
+
"pytest-mock>=3.15,<4.0",
|
|
38
|
+
"python-semantic-release>=10.0.0,<11.0.0",
|
|
39
|
+
"ruff>=0.17,<1.0.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[tool.semantic_release]
|
|
43
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
44
|
+
commit_parser = "conventional"
|
|
45
|
+
tag_format = "v{version}"
|
|
46
|
+
allow_zero_version = true
|
|
47
|
+
major_on_zero = false
|
|
48
|
+
|
|
49
|
+
[tool.semantic_release.branches.main]
|
|
50
|
+
match = "(main|master)"
|
|
51
|
+
|
|
52
|
+
[tool.semantic_release.changelog]
|
|
53
|
+
mode = "update"
|
|
54
|
+
insertion_flag = "<!-- version list -->"
|
|
55
|
+
|
|
56
|
+
[tool.semantic_release.changelog.default_templates]
|
|
57
|
+
changelog_file = "CHANGELOG.md"
|
|
58
|
+
output_format = "md"
|
|
59
|
+
mask_initial_release = true
|
|
60
|
+
|
|
61
|
+
[tool.semantic_release.commit_parser_options]
|
|
62
|
+
minor_tags = ["feat"]
|
|
63
|
+
patch_tags = [
|
|
64
|
+
"fix",
|
|
65
|
+
"perf",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
[tool.semantic_release.remote]
|
|
69
|
+
type = "github"
|
|
70
|
+
|
|
71
|
+
[tool.semantic_release.publish]
|
|
72
|
+
dist_glob_patterns = ["dist/*"]
|
|
73
|
+
upload_to_vcs_release = true
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
mypy_path = "src"
|
|
77
|
+
ignore_missing_imports = true
|
|
78
|
+
|
|
79
|
+
[tool.pytest.ini_options]
|
|
80
|
+
addopts = "-m 'not live'"
|
|
81
|
+
markers = ["live: checks against godot-builds releases"]
|
|
82
|
+
|
|
83
|
+
[tool.ruff.lint]
|
|
84
|
+
extend-select = ["G004"]
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "godotkit"
|
|
3
|
+
version = "0.8.1"
|
|
4
|
+
description = "Python utilities and classes for working with Godot engine releases and projects."
|
|
5
|
+
license = "MIT"
|
|
6
|
+
license-files = ["LICENSE"]
|
|
7
|
+
readme = "README.md"
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "KROSSEYE", email = "30990184+KROSSEYE@users.noreply.github.com" },
|
|
10
|
+
]
|
|
11
|
+
requires-python = ">=3.11"
|
|
12
|
+
dependencies = ["filelock>=4.0,<5.0.0", "httpx>=0.28,<1.0.0"]
|
|
13
|
+
|
|
14
|
+
[project.urls]
|
|
15
|
+
Homepage = "https://github.com/krosseye/godotkit"
|
|
16
|
+
Documentation = "https://krosseye.github.io/godotkit/"
|
|
17
|
+
Changelog = "https://github.com/krosseye/godotkit/blob/main/CHANGELOG.md"
|
|
18
|
+
Issues = "https://github.com/krosseye/godotkit/issues"
|
|
19
|
+
|
|
20
|
+
[build-system]
|
|
21
|
+
requires = ["uv_build>=0.8.15,<0.14.0"]
|
|
22
|
+
build-backend = "uv_build"
|
|
23
|
+
|
|
24
|
+
[dependency-groups]
|
|
25
|
+
dev = [
|
|
26
|
+
"mkdocs>=1.6.0,<2.0.0",
|
|
27
|
+
"mkdocs-material>=9.8.0,<10.0.0",
|
|
28
|
+
"mkdocstrings[python]>=1.0.0,<2.0.0",
|
|
29
|
+
"mypy>=2.4,<3.0.0",
|
|
30
|
+
"prek>=0.5.0,<1.0.0",
|
|
31
|
+
"pytest>=9.0.0,<10.0.0",
|
|
32
|
+
"pytest-asyncio>=1.4.0",
|
|
33
|
+
"pytest-mock>=3.15,<4.0",
|
|
34
|
+
"python-semantic-release>=10.0.0,<11.0.0",
|
|
35
|
+
"ruff>=0.17,<1.0.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[tool.semantic_release]
|
|
39
|
+
version_toml = ["pyproject.toml:project.version"]
|
|
40
|
+
commit_parser = "conventional"
|
|
41
|
+
tag_format = "v{version}"
|
|
42
|
+
allow_zero_version = true
|
|
43
|
+
major_on_zero = false
|
|
44
|
+
|
|
45
|
+
[tool.semantic_release.branches.main]
|
|
46
|
+
match = "(main|master)"
|
|
47
|
+
|
|
48
|
+
[tool.semantic_release.changelog]
|
|
49
|
+
mode = "update"
|
|
50
|
+
insertion_flag = "<!-- version list -->"
|
|
51
|
+
|
|
52
|
+
[tool.semantic_release.changelog.default_templates]
|
|
53
|
+
changelog_file = "CHANGELOG.md"
|
|
54
|
+
output_format = "md"
|
|
55
|
+
mask_initial_release = true
|
|
56
|
+
|
|
57
|
+
[tool.semantic_release.commit_parser_options]
|
|
58
|
+
minor_tags = ["feat"]
|
|
59
|
+
patch_tags = ["fix", "perf"]
|
|
60
|
+
|
|
61
|
+
[tool.semantic_release.remote]
|
|
62
|
+
type = "github"
|
|
63
|
+
|
|
64
|
+
[tool.semantic_release.publish]
|
|
65
|
+
dist_glob_patterns = ["dist/*"]
|
|
66
|
+
upload_to_vcs_release = true
|
|
67
|
+
|
|
68
|
+
[tool.mypy]
|
|
69
|
+
mypy_path = "src"
|
|
70
|
+
ignore_missing_imports = true
|
|
71
|
+
|
|
72
|
+
[tool.pytest.ini_options]
|
|
73
|
+
addopts = "-m 'not live'"
|
|
74
|
+
markers = ["live: checks against godot-builds releases"]
|
|
75
|
+
|
|
76
|
+
[tool.ruff.lint]
|
|
77
|
+
extend-select = ["G004"]
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .core import (
|
|
2
|
+
launch_daemon_command,
|
|
3
|
+
open_directory,
|
|
4
|
+
remove_directory,
|
|
5
|
+
run_utility_command,
|
|
6
|
+
)
|
|
7
|
+
from .git import clone, git_installed, init_repo
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"clone",
|
|
11
|
+
"git_installed",
|
|
12
|
+
"init_repo",
|
|
13
|
+
"launch_daemon_command",
|
|
14
|
+
"open_directory",
|
|
15
|
+
"remove_directory",
|
|
16
|
+
"run_utility_command",
|
|
17
|
+
]
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import os
|
|
3
|
+
import platform
|
|
4
|
+
import shutil
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def open_directory(path: Path) -> None:
|
|
13
|
+
"""
|
|
14
|
+
Opens the given directory in the native file manager.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
path (Path): The path to the directory to open.
|
|
18
|
+
|
|
19
|
+
Raises:
|
|
20
|
+
ValueError: If the provided path is not a valid directory.
|
|
21
|
+
NotImplementedError: If the current platform is unsupported.
|
|
22
|
+
"""
|
|
23
|
+
if not path.is_dir():
|
|
24
|
+
raise ValueError("Invalid directory path")
|
|
25
|
+
|
|
26
|
+
current_platform = platform.system().lower()
|
|
27
|
+
|
|
28
|
+
if current_platform == "windows" and hasattr(os, "startfile"):
|
|
29
|
+
os.startfile(str(path))
|
|
30
|
+
elif current_platform == "darwin":
|
|
31
|
+
run_utility_command(["open", str(path)])
|
|
32
|
+
elif current_platform == "linux":
|
|
33
|
+
run_utility_command(["xdg-open", str(path)])
|
|
34
|
+
else:
|
|
35
|
+
raise NotImplementedError(f"Unsupported platform: {current_platform}")
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def remove_directory(dir_path: Path) -> None:
|
|
39
|
+
"""Recursively deletes a directory and all its contents.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
dir_path (Path): Path to the directory to delete.
|
|
43
|
+
|
|
44
|
+
Raises:
|
|
45
|
+
ValueError: If the path does not exist or is not a directory.
|
|
46
|
+
OSError: If an OS-related error occurs during deletion.
|
|
47
|
+
PermissionError: If the process lacks permission to delete files or subdirectories.
|
|
48
|
+
"""
|
|
49
|
+
if not dir_path.is_dir():
|
|
50
|
+
msg = f"Invalid directory path: '{dir_path}'"
|
|
51
|
+
logger.error(msg)
|
|
52
|
+
raise ValueError(msg)
|
|
53
|
+
try:
|
|
54
|
+
shutil.rmtree(dir_path)
|
|
55
|
+
logger.info("Removed directory '%s'", dir_path)
|
|
56
|
+
except Exception:
|
|
57
|
+
logger.exception("Failed to remove directory '%s'", dir_path)
|
|
58
|
+
raise
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def run_utility_command(
|
|
62
|
+
command: list[str],
|
|
63
|
+
working_dir: Path | None = None,
|
|
64
|
+
timeout: int | None = None,
|
|
65
|
+
) -> subprocess.CompletedProcess:
|
|
66
|
+
"""Runs a system command, waits for it to complete, and captures output.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
command (List[str]): Command and arguments, e.g. ['ls', '-l'].
|
|
70
|
+
working_dir (Optional[Path]): Working directory for the command.
|
|
71
|
+
timeout (Optional[int]): Timeout in seconds.
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
subprocess.CompletedProcess: Result object containing stdout, stderr, and return code.
|
|
75
|
+
|
|
76
|
+
Raises:
|
|
77
|
+
subprocess.CalledProcessError: If the command fails (non-zero return code).
|
|
78
|
+
subprocess.TimeoutExpired: If the command times out.
|
|
79
|
+
ValueError: If the working directory is invalid.
|
|
80
|
+
"""
|
|
81
|
+
cmd_str = " ".join(command)
|
|
82
|
+
logger.debug("Executing utility command: %s", cmd_str)
|
|
83
|
+
|
|
84
|
+
if working_dir is not None and not working_dir.is_dir():
|
|
85
|
+
raise ValueError(f"Invalid working directory: {working_dir}")
|
|
86
|
+
|
|
87
|
+
return subprocess.run(
|
|
88
|
+
command,
|
|
89
|
+
cwd=None if working_dir is None else str(working_dir),
|
|
90
|
+
timeout=timeout,
|
|
91
|
+
check=True,
|
|
92
|
+
capture_output=True,
|
|
93
|
+
text=True,
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def launch_daemon_command(
|
|
98
|
+
command: list[str],
|
|
99
|
+
working_dir: Path | None = None,
|
|
100
|
+
) -> None:
|
|
101
|
+
"""Launches a system command in a non-blocking, detached manner.
|
|
102
|
+
|
|
103
|
+
Args:
|
|
104
|
+
command (List[str]): Command and arguments, e.g. ['xdg-open', 'file.pdf'].
|
|
105
|
+
working_dir (Optional[Path]): Working directory for the command.
|
|
106
|
+
|
|
107
|
+
Raises:
|
|
108
|
+
ValueError: If the working directory is invalid.
|
|
109
|
+
"""
|
|
110
|
+
cmd_str = " ".join(command)
|
|
111
|
+
logger.debug("Launching background command: %s", cmd_str)
|
|
112
|
+
|
|
113
|
+
if working_dir is not None and not working_dir.is_dir():
|
|
114
|
+
raise ValueError(f"Invalid working directory: {working_dir}")
|
|
115
|
+
|
|
116
|
+
if sys.platform == "win32":
|
|
117
|
+
creationflags = (
|
|
118
|
+
subprocess.CREATE_NEW_PROCESS_GROUP | subprocess.DETACHED_PROCESS
|
|
119
|
+
)
|
|
120
|
+
subprocess.Popen(
|
|
121
|
+
command,
|
|
122
|
+
cwd=None if working_dir is None else str(working_dir),
|
|
123
|
+
creationflags=creationflags,
|
|
124
|
+
stdout=subprocess.DEVNULL,
|
|
125
|
+
stderr=subprocess.DEVNULL,
|
|
126
|
+
)
|
|
127
|
+
else:
|
|
128
|
+
subprocess.Popen(
|
|
129
|
+
command,
|
|
130
|
+
cwd=None if working_dir is None else str(working_dir),
|
|
131
|
+
start_new_session=True,
|
|
132
|
+
stdout=subprocess.DEVNULL,
|
|
133
|
+
stderr=subprocess.DEVNULL,
|
|
134
|
+
)
|