Compare commits
9 Commits
v0.0.4
...
dc2d1ab3a0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc2d1ab3a0 | ||
|
|
983c6cefea | ||
|
|
a977884e17 | ||
|
|
20fb85a3f0 | ||
|
|
f4efb1daae | ||
|
|
fb181f8810 | ||
|
|
3dee7784e2 | ||
| cc560770ce | |||
| 4df903783c |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,7 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH <support@kunbus.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|||||||
40
.gitlab-ci.yml
Normal file
40
.gitlab-ci.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH <support@kunbus.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
default:
|
||||||
|
tags:
|
||||||
|
- self-hosted
|
||||||
|
- host-arm64
|
||||||
|
- high-perf
|
||||||
|
|
||||||
|
include:
|
||||||
|
- project: "revolutionpi/infrastructure/ci-templates"
|
||||||
|
file: "base.yml"
|
||||||
|
- project: "revolutionpi/infrastructure/ci-templates"
|
||||||
|
file: "check-commit/lint-commit.yml"
|
||||||
|
- project: "revolutionpi/infrastructure/ci-templates"
|
||||||
|
file: "reuse-lint.yml"
|
||||||
|
- project: "revolutionpi/infrastructure/ci-templates"
|
||||||
|
file: "package-devel.yml"
|
||||||
|
- local: debian/gitlab-ci.yml
|
||||||
|
rules:
|
||||||
|
- exists:
|
||||||
|
- debian/gitlab-ci.yml
|
||||||
|
|
||||||
|
run_tests:
|
||||||
|
stage: test
|
||||||
|
image: python:3.11-bookworm
|
||||||
|
script:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get -y install dbus libgirepository1.0-dev
|
||||||
|
- dbus-uuidgen --ensure=/etc/machine-id
|
||||||
|
- pip install -r requirements.txt
|
||||||
|
- PYTHONPATH=src dbus-run-session -- pytest -v --junitxml=report.xml --cov=src --cov-report term --cov-report xml:coverage.xml
|
||||||
|
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
|
||||||
|
artifacts:
|
||||||
|
reports:
|
||||||
|
junit: ${CI_PROJECT_DIR}/report.xml
|
||||||
|
coverage_report:
|
||||||
|
coverage_format: cobertura
|
||||||
|
path: coverage.xml
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH <support@kunbus.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
recursive-include .reuse *
|
recursive-include .reuse *
|
||||||
recursive-include data *
|
recursive-include data *
|
||||||
recursive-include LICENSES *
|
recursive-include LICENSES *
|
||||||
|
|||||||
4
Makefile
4
Makefile
@@ -1,3 +1,7 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH <support@kunbus.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
SHELL := bash
|
SHELL := bash
|
||||||
MAKEFLAGS = --no-print-directory --no-builtin-rules
|
MAKEFLAGS = --no-print-directory --no-builtin-rules
|
||||||
.DEFAULT_GOAL = all
|
.DEFAULT_GOAL = all
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: 2025 KUNBUS GmbH <support@kunbus.com>
|
||||||
|
|
||||||
|
SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
-->
|
||||||
|
|
||||||
# Middleware for Revolution Pi
|
# Middleware for Revolution Pi
|
||||||
|
|
||||||
This middleware will support D-Bus as IPC interface.
|
This middleware will support D-Bus as IPC interface.
|
||||||
|
|||||||
@@ -1,2 +1,6 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH <support@kunbus.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
[tool.black]
|
[tool.black]
|
||||||
line-length = 100
|
line-length = 100
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH <support@kunbus.com>
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
# Build dependencies
|
# Build dependencies
|
||||||
pip-licenses
|
pip-licenses
|
||||||
Pyinstaller
|
Pyinstaller
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from glob import glob
|
|||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from os import X_OK, access
|
from os import X_OK, access
|
||||||
from os.path import exists, join
|
from os.path import exists, join
|
||||||
|
from threading import Thread
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
from pydbus import SystemBus
|
from pydbus import SystemBus
|
||||||
@@ -665,13 +666,39 @@ def simple_systemd(action: ConfigActions, unit: str):
|
|||||||
systemd_manager = systemd["org.freedesktop.systemd1.Manager"]
|
systemd_manager = systemd["org.freedesktop.systemd1.Manager"]
|
||||||
|
|
||||||
if action is ConfigActions.ENABLE:
|
if action is ConfigActions.ENABLE:
|
||||||
systemd_manager.UnmaskUnitFiles([unit], False)
|
|
||||||
systemd_manager.EnableUnitFiles([unit], False, False)
|
def thread_unit_config():
|
||||||
|
"""Change configuration asynchronously."""
|
||||||
|
# Dbus call: UnmaskUnitFiles(in as files, in b runtime, out a(sss) changes
|
||||||
|
lst_change_unmask = systemd_manager.UnmaskUnitFiles([unit], False)
|
||||||
|
|
||||||
|
# Dbus call: EnableUnitFiles(in as files, in b runtime, in b force,
|
||||||
|
# out b carries_install_info, out a(sss) changes
|
||||||
|
lst_change_enable = systemd_manager.EnableUnitFiles([unit], False, False)
|
||||||
|
if lst_change_unmask or lst_change_enable:
|
||||||
|
# Reload systemd after modified unit property
|
||||||
|
systemd_manager.Reload()
|
||||||
|
|
||||||
|
Thread(target=thread_unit_config, daemon=True).start()
|
||||||
|
|
||||||
|
# Dbus call: StartUnit(in s name, in s mode, out o job
|
||||||
systemd_manager.StartUnit(unit, "replace")
|
systemd_manager.StartUnit(unit, "replace")
|
||||||
|
|
||||||
elif action is ConfigActions.DISABLE:
|
elif action is ConfigActions.DISABLE:
|
||||||
|
|
||||||
|
def thread_unit_config():
|
||||||
|
"""Change configuration asynchronously."""
|
||||||
|
# Dbus call: DisableUnitFiles (in as files, in b runtime, out a(sss) changes)
|
||||||
|
change = systemd_manager.DisableUnitFiles([unit], False)
|
||||||
|
if change:
|
||||||
|
# Reload systemd after modified unit property
|
||||||
|
systemd_manager.Reload()
|
||||||
|
|
||||||
|
Thread(target=thread_unit_config, daemon=True).start()
|
||||||
|
|
||||||
|
# Dbus call: StopUnit(in s name,in s mode, out o job
|
||||||
systemd_manager.StopUnit(unit, "replace")
|
systemd_manager.StopUnit(unit, "replace")
|
||||||
systemd_manager.DisableUnitFiles([unit], False)
|
|
||||||
|
|
||||||
elif action is ConfigActions.STATUS:
|
elif action is ConfigActions.STATUS:
|
||||||
try:
|
try:
|
||||||
@@ -696,6 +723,8 @@ def simple_systemd(action: ConfigActions, unit: str):
|
|||||||
else:
|
else:
|
||||||
raise ValueError(f"action {action} not supported")
|
raise ValueError(f"action {action} not supported")
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
rc = RevPiConfig()
|
rc = RevPiConfig()
|
||||||
|
|||||||
Reference in New Issue
Block a user