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

feat/network_reqs_from_workshop #96

Merged
merged 1 commit into from
Feb 4, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions ovos_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
from ovos_utils.network_utils import get_ip, get_external_ip, is_connected_dns, is_connected_http, is_connected


class classproperty(property):
"""Decorator for a Class-level property.
Credit to Denis Rhyzhkov on Stackoverflow: https://stackoverflow.com/a/13624858/1280629"""
def __get__(self, owner_self, owner_cls):
return self.fget(owner_cls)


def ensure_mycroft_import():
try:
import mycroft
Expand Down
22 changes: 22 additions & 0 deletions ovos_utils/network_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
import socket
import requests
from dataclasses import dataclass


@dataclass
class NetworkRequirements:
# to ensure backwards compatibility the default values require internet before skill loading
# skills in the wild may assume this behaviour and require network on initialization
# any ovos aware skills should change these as appropriate

# xxx_before_load is used by skills service
network_before_load: bool = True
internet_before_load: bool = True

# requires_xxx is currently purely informative and not consumed by core
# this allows a skill to spec if it needs connectivity to handle utterances
requires_internet: bool = True
requires_network: bool = True

# xxx_fallback is currently purely informative and not consumed by core
# this allows a skill to spec if it has a fallback for temporary offline events, eg, by having a cache
no_internet_fallback: bool = False
no_network_fallback: bool = False


def get_ip():
Expand Down