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

Release 1.1.0a1 #45

Merged
merged 3 commits into from
Dec 3, 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
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Changelog

## [1.0.3a1](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/tree/1.0.3a1) (2024-12-02)
## [1.1.0a1](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/tree/1.1.0a1) (2024-12-03)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/compare/V1.0.2...1.0.3a1)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/compare/V1.0.3...1.1.0a1)

**Merged pull requests:**

- fix: remove deprecated backend client [\#42](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/pull/42) ([JarbasAl](https://github.com/JarbasAl))
- feat: status events [\#44](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/pull/44) ([JarbasAl](https://github.com/JarbasAl))

## [V1.0.2](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/tree/V1.0.2) (2024-11-29)
## [V1.0.3](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/tree/V1.0.3) (2024-12-02)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/compare/1.0.2...V1.0.2)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/compare/1.0.3...V1.0.3)



Expand Down
70 changes: 47 additions & 23 deletions ovos_PHAL_plugin_system/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,17 @@ def __init__(self, bus=None, config=None):
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.ssh.enabled", self.handle_ssh_enabled)
self.bus.on("system.ssh.disabled", self.handle_ssh_disabled)
self.bus.on("system.reboot", self.handle_reboot_request)
self.bus.on("system.reboot.start", self.handle_rebooting)
self.bus.on("system.shutdown", self.handle_shutdown_request)
self.bus.on("system.shutdown.start", self.handle_shutting_down)
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)
self.bus.on("system.configure.language", self.handle_configure_language_request)
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"
# In Debian, ssh stays active, but sshd is removed when ssh is disabled
Expand Down Expand Up @@ -85,7 +88,7 @@ def use_external_factory_reset(self):
return True
return external_requested or False

def handle_reset_register(self, message):
def handle_reset_register(self, message: Message):
if not message.data.get("skill_id"):
LOG.warning(f"Got registration request without a `skill_id`: "
f"{message.data}")
Expand All @@ -99,7 +102,7 @@ def handle_reset_register(self, message):
if sid not in self.factory_reset_plugs:
self.factory_reset_plugs.append(sid)

def handle_factory_reset_request(self, message):
def handle_factory_reset_request(self, message: Message):
LOG.debug(f'Factory reset request: {message.data}')
self.bus.emit(message.forward("system.factory.reset.start"))
self.bus.emit(message.forward("system.factory.reset.ping"))
Expand Down Expand Up @@ -191,54 +194,71 @@ def on_done(message):
if reboot:
self.bus.emit(message.forward("system.reboot"))

def handle_ssh_enable_request(self, message):
def handle_ssh_enable_request(self, message: Message):
subprocess.call(f"systemctl enable {self.ssh_service}", shell=True)
subprocess.call(f"systemctl start {self.ssh_service}", shell=True)
self.bus.emit(message.forward("system.ssh.enabled", message.data))

def handle_ssh_enabled(self, message: Message):
# ovos-shell does not want to display
if message.data.get("display", True):
self.gui["status"] = "Enabled"
self.gui["label"] = "SSH Enabled"
self.gui.show_page("Status")

def handle_ssh_disable_request(self, message):
def handle_ssh_disable_request(self, message: Message):
subprocess.call(f"systemctl stop {self.ssh_service}", shell=True)
subprocess.call(f"systemctl disable {self.ssh_service}", shell=True)
self.bus.emit(message.forward("system.ssh.disabled", message.data))

def handle_ssh_disabled(self, message: Message):
# ovos-shell does not want to display
if message.data.get("display", True):
self.gui["status"] = "Disabled"
self.gui["label"] = "SSH Disabled"
self.gui.show_page("Status")

def handle_reboot_request(self, message):
def handle_rebooting(self, message: Message):
"""
Shut down and restart the system
reboot has started
"""
if message.data.get("display", True):
self.gui.show_page("Reboot", override_animations=True,
override_idle=True)

def handle_reboot_request(self, message: Message):
"""
Shut down and restart the system
"""
self.bus.emit(message.forward("system.reboot.start", message.data))
script = os.path.expanduser(self.config.get("reboot_script") or "")
LOG.info(f"Reboot requested. script={script}")
if script and os.path.isfile(script):
subprocess.call(script, shell=True)
else:
subprocess.call("systemctl reboot -i", shell=True)

def handle_shutdown_request(self, message):
def handle_shutting_down(self, message: Message):
"""
Turn the system completely off (with no option to inhibit it)
shutdown has started
"""
if message.data.get("display", True):
self.gui.show_page("Shutdown", override_animations=True,
override_idle=True)

def handle_shutdown_request(self, message: Message):
"""
Turn the system completely off (with no option to inhibit it)
"""
self.bus.emit(message.forward("system.shutdown.start", message.data))
script = os.path.expanduser(self.config.get("shutdown_script") or "")
LOG.info(f"Shutdown requested. script={script}")
if script and os.path.isfile(script):
subprocess.call(script, shell=True)
else:
subprocess.call("systemctl poweroff -i", shell=True)

def handle_configure_language_request(self, message):
def handle_configure_language_request(self, message: Message):
language_code = message.data.get('language_code', "en_US")
with open(f"{os.environ['HOME']}/.bash_profile",
"w") as bash_profile_file:
Expand All @@ -259,11 +279,14 @@ def handle_configure_language_request(self, message):
self.bus.emit(Message('system.configure.language.complete',
{"lang": language_code}))

def handle_mycroft_restart_request(self, message):
def handle_mycroft_restarting(self, message: Message):
if message.data.get("display", True):
self.gui.show_page("Restart", override_animations=True,
override_idle=True)

def handle_mycroft_restart_request(self, message: Message):
service = self.core_service_name
self.bus.emit(message.forward("system.mycroft.service.restart.start", message.data))
# TODO - clean up this mess
try:
restart_service(service, sudo=False, user=True)
Expand All @@ -274,7 +297,7 @@ def handle_mycroft_restart_request(self, message):
LOG.error("No mycroft or ovos service installed")
return False

def handle_ssh_status(self, message):
def handle_ssh_status(self, message: Message):
"""
Check SSH service status and emit a response
"""
Expand All @@ -284,16 +307,17 @@ def handle_ssh_status(self, message):
def shutdown(self):
self.bus.remove("system.ssh.enable", self.handle_ssh_enable_request)
self.bus.remove("system.ssh.disable", self.handle_ssh_disable_request)
self.bus.remove("system.ssh.enabled", self.handle_ssh_enabled)
self.bus.remove("system.ssh.disabled", self.handle_ssh_disabled)
self.bus.remove("system.reboot", self.handle_reboot_request)
self.bus.remove("system.reboot.start", self.handle_rebooting)
self.bus.remove("system.shutdown", self.handle_shutdown_request)
self.bus.remove("system.factory.reset",
self.handle_factory_reset_request)
self.bus.remove("system.factory.reset.register",
self.handle_reset_register)
self.bus.remove("system.configure.language",
self.handle_configure_language_request)
self.bus.remove("system.mycroft.service.restart",
self.handle_mycroft_restart_request)
self.bus.remove("system.shutdown.start", self.handle_shutting_down)
self.bus.remove("system.factory.reset", self.handle_factory_reset_request)
self.bus.remove("system.factory.reset.register", self.handle_reset_register)
self.bus.remove("system.configure.language", self.handle_configure_language_request)
self.bus.remove("system.mycroft.service.restart", self.handle_mycroft_restart_request)
self.bus.remove("system.mycroft.service.restart.start", self.handle_mycroft_restarting)
super().shutdown()


Expand Down
6 changes: 3 additions & 3 deletions ovos_PHAL_plugin_system/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_BUILD = 3
VERSION_ALPHA = 0
VERSION_MINOR = 1
VERSION_BUILD = 0
VERSION_ALPHA = 1
# END_VERSION_BLOCK