Skip to content

Commit

Permalink
Refactor into Neon package
Browse files Browse the repository at this point in the history
Revert Changes from OpenVoiceOS#48 that added ovos-config>0.X dependency
  • Loading branch information
NeonDaniel committed Dec 28, 2024
1 parent 21e6726 commit d09ffea
Show file tree
Hide file tree
Showing 18 changed files with 333 additions and 238 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/conventional-label.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/propose_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Propose Stable Release
on:
workflow_dispatch:
inputs:
release_type:
type: choice
description: Release Type
options:
- patch
- minor
- major
jobs:
update_version:
uses: neongeckocom/.github/.github/workflows/propose_semver_release.yml@master
with:
branch: dev
release_type: ${{ inputs.release_type }}
update_changelog: True
version_file: neon_phal_plugin_system/version.py
alpha_var: VERSION_ALPHA
build_var: VERSION_BUILD
minor_var: VERSION_MINOR
major_var: VERSION_MAJOR
pull_changes:
uses: neongeckocom/.github/.github/workflows/pull_master.yml@master
needs: update_version
with:
pr_reviewer: neonreviewers
pr_assignee: ${{ github.actor }}
pr_draft: false
pr_title: ${{ needs.update_version.outputs.version }}
pr_body: ${{ needs.update_version.outputs.changelog }}
12 changes: 12 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This workflow will generate a release distribution and upload it to PyPI

name: Publish Build and GitHub Release
on:
push:
branches:
- master

jobs:
build_and_publish_pypi_and_release:
uses: neongeckocom/.github/.github/workflows/publish_stable_release.yml@master
secrets: inherit
72 changes: 0 additions & 72 deletions .github/workflows/publish_stable.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/publish_test_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# This workflow will generate a distribution and upload it to PyPI

name: Publish Alpha Build
on:
push:
branches:
- dev
paths-ignore:
- 'neon_phal_plugin_system/version.py'

jobs:
publish_alpha_release:
uses: neongeckocom/.github/.github/workflows/publish_alpha_release.yml@master
secrets: inherit
with:
version_file: "neon_phal_plugin_system/version.py"
alpha_var: VERSION_ALPHA
build_var: VERSION_BUILD
minor_var: VERSION_MINOR
major_var: VERSION_MAJOR
publish_prerelease: true
update_changelog: true
108 changes: 0 additions & 108 deletions .github/workflows/release_workflow.yml

This file was deleted.

8 changes: 6 additions & 2 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Unit Tests
# This workflow will run unit tests

name: Run Unit Tests
on:
push:
workflow_dispatch:

pull_request:
branches:
- master
jobs:
py_build_tests:
uses: neongeckocom/.github/.github/workflows/python_build_tests.yml@master
Expand Down
38 changes: 9 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
# ovos-PHAL-plugin - system
# neon-phal-plugin-system

Provides system specific commands to OVOS.
Provides system specific commands to Neon.
The dbus interface for this plugin is not yet established.

# Install

`pip install ovos-PHAL-plugin-system`
`pip install neon-phal-plugin-system`

# Config

This plugin is a Admin plugin, it needs to run as root and to be explicitly enabled in mycroft.conf
This plugin is an Admin plugin, it needs to run as root and to be explicitly enabled in mycroft.conf

```javascript
{
"PHAL": {
"admin": {
"ovos-PHAL-plugin-system": {"enabled": true}
}
}
}
```
if not enabled (omit config above) it will be run as the regular user, you need to ensure [polkit policy](#) is set to allow usage of systemctl without sudo. Not yet implemented


handle bus events to interact with the OS

```python
self.bus.on("system.ntp.sync", self.handle_ntp_sync_request)
self.bus.on("system.ssh.status", self.handle_ssh_status)
self.bus.on("system.ssh.enable", self.handle_ssh_enable_request)
self.bus.on("system.ssh.disable", self.handle_ssh_disable_request)
self.bus.on("system.reboot", self.handle_reboot_request)
self.bus.on("system.shutdown", self.handle_shutdown_request)
self.bus.on("system.factory.reset", self.handle_factory_reset_request)
self.bus.on("system.factory.reset.register", self.handle_reset_register)
self.bus.on("system.configure.language", self.handle_configure_language_request)
self.bus.on("system.mycroft.service.restart", self.handle_mycroft_restart_request)
```yaml
PHAL:
admin:
neon-phal-plugin-system:
enabled: true
```
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ def validate(config=None):
This allows a plugin to run platform checks"""
# check if admin plugin is not enabled
cfg = Configuration().get("PHAL", {}).get("admin", {})
if cfg.get("ovos-PHAL-plugin-system", {}).get("enabled"):
if cfg.get("neon-phal-plugin-system", {}).get("enabled"):
# run this plugin in admin mode (as root)
return False

LOG.info("ovos-PHAL-plugin-system running as user")
LOG.info("neon-phal-plugin-system running as user")
return True


class SystemEventsPlugin(PHALPlugin):
validator = SystemEventsValidator

def __init__(self, bus=None, config=None):
super().__init__(bus=bus, name="ovos-PHAL-plugin-system", config=config)
super().__init__(bus=bus, name="neon-phal-plugin-system", config=config)
self.gui = GUIInterface(bus=self.bus, skill_id=self.name,
config=self.config_core.get('gui'))
self.bus.on("system.ssh.status", self.handle_ssh_status)
Expand All @@ -60,10 +60,9 @@ def __init__(self, bus=None, config=None):
self.bus.on("system.mycroft.service.restart", self.handle_mycroft_restart_request)
self.bus.on("system.mycroft.service.restart.start", self.handle_mycroft_restarting)

self.core_service_name = config.get("core_service") or "ovos.service"
self.core_service_name = config.get("core_service") or "neon.service"
# In Debian, ssh stays active, but sshd is removed when ssh is disabled
self.ssh_service = config.get("ssh_service") or "sshd.service"
self.use_root = config.get("sudo", True)

self.factory_reset_plugs = []

Expand Down Expand Up @@ -325,7 +324,7 @@ def shutdown(self):
class SystemEventsAdminValidator(AdminValidator, SystemEventsValidator):
@staticmethod
def validate(config=None):
LOG.info("ovos-PHAL-plugin-system running as root")
LOG.info("neon-phal-plugin-system running as root")
return True


Expand Down
Loading

0 comments on commit d09ffea

Please sign in to comment.