Skip to content

Commit

Permalink
Add check and spoken error if requested update while offline (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Jun 6, 2023
1 parent eb201e5 commit dd02e56
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from ovos_utils import classproperty
from ovos_utils.log import LOG
from ovos_utils.process_utils import RuntimeRequirements
from ovos_utils.network_utils import is_connected_http
from neon_utils.skills import NeonSkill
from neon_utils.user_utils import get_user_prefs
from mycroft.skills import intent_file_handler, intent_handler
Expand Down Expand Up @@ -140,6 +141,12 @@ def handle_update_device(self, message):
self.speak_dialog("check_error")
return

# TODO: Support alternate update sources?
if not is_connected_http("https://github.com"):
LOG.warning(f"GitHub not available. Skipping update")
self.speak_dialog("error_offline")
return

if self.current_ver == self.latest_ver:
resp = self.ask_yesno(
"up_to_date",
Expand Down
1 change: 1 addition & 0 deletions locale/en-us/dialog/error_offline.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sorry, I can't start an update without a connection to git hub dot com.
1 change: 1 addition & 0 deletions test/test_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ dialog:
- "confirm_change_update_track"
- "confirm_no_change_update_track"
- "core_version"
- "error_offline"
# regex entities, not necessarily filenames
regex: []
intents:
Expand Down
2 changes: 2 additions & 0 deletions test/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def check_update(message: Message):
self.assertEqual(start_update.call_args[0][0].data,
{"version": new_ver})

# TODO: Test offline

self.skill.ask_yesno = real_ask_yesno

def test_handle_switch_update_track(self):
Expand Down

0 comments on commit dd02e56

Please sign in to comment.