Skip to content

Commit

Permalink
Merge pull request #47 from OpenVoiceOS/release-1.2.0a1
Browse files Browse the repository at this point in the history
Release 1.2.0a1
  • Loading branch information
JarbasAl authored Dec 3, 2024
2 parents 5b1bea6 + 774ef1e commit 657ad44
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 32 deletions.
18 changes: 13 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# Changelog

## [1.0.3a1](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/tree/1.0.3a1) (2024-12-02)
## [1.2.0a1](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/tree/1.2.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/1.1.0a1...1.2.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:clock\_sync\_gui [\#46](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/pull/46) ([JarbasAl](https://github.com/JarbasAl))

## [V1.0.2](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/tree/V1.0.2) (2024-11-29)
## [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/1.0.2...V1.0.2)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-system/compare/V1.0.3...1.1.0a1)

**Merged pull requests:**

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

## [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.3...V1.0.3)



Expand Down
79 changes: 55 additions & 24 deletions ovos_PHAL_plugin_system/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ 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.clock.synced", self.handle_clock_sync)
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 +89,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 +103,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 +195,76 @@ def on_done(message):
if reboot:
self.bus.emit(message.forward("system.reboot"))

def handle_ssh_enable_request(self, message):
def handle_clock_sync(self, message: Message):
if message.data.get("display", True):
self.gui["status"] = "Enabled"
self.gui["label"] = "Clock Synchronized"
self.gui.show_page("Status")

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)
# ovos-shell does not want to display
self.bus.emit(message.forward("system.ssh.enabled", message.data))

def handle_ssh_enabled(self, message: Message):
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 +285,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 +303,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 +313,18 @@ 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)
self.bus.remove("system.clock.synced", self.handle_clock_sync)
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 = 2
VERSION_BUILD = 0
VERSION_ALPHA = 1
# END_VERSION_BLOCK

0 comments on commit 657ad44

Please sign in to comment.