Skip to content

Commit

Permalink
feat/network_reqs_from_workshop (#96)
Browse files Browse the repository at this point in the history
move shared utils from workshop for usage across more projects
  • Loading branch information
JarbasAl committed Feb 4, 2023
1 parent faca9d0 commit f399f0a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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

0 comments on commit f399f0a

Please sign in to comment.