def __init__(self, snips=None, config=None): """Initialize a Snips app using the Hermes protocol. Args: snips (:class:`.SnipsConfig`, optional): a Snips configuration. If the argument is not specified, a default :class:`.SnipsConfig` object is created for a locally installed instance of Snips. config (:class:`.AppConfig`, optional): an app configuration. If the argument is not specified, the app has no configuration. """ SnipsAppMixin.__init__(self, snips, config) HermesSnipsComponent.__init__(self, snips)
from pathlib import Path import socket from urllib.error import URLError import arrow import psutil from snipskit.apps import SnipsAppMixin from snipskit.hermes.apps import HermesSnipsApp from snipskit.hermes.decorators import intent from snipskit.services import version from snipskit.tools import latest_snips_version # Use the assistant's language. i18n = importlib.import_module('translations.' + SnipsAppMixin().assistant['language']) class AssistantInformation(HermesSnipsApp): """ This app answers questions about your Snips assistant. """ @intent(i18n.INTENT_ASSISTANT_APPS) def handle_assistant_apps(self, hermes, intent_message): """Handle the intent AssistantApps.""" # Look at the snippets directory and not in Snipsfile.yaml. # The former also contains apps with inline snippets, # the latter doesn't. apps = [ str(app) for app in (Path(self.assistant.filename).parent /
#!/usr/bin/env python3 # -*-: coding utf-8 -*- import ConfigParser from coffeehack.coffeehack import CoffeeHack from hermes_python.hermes import Hermes import io import Queue import importlib from snipskit.apps import SnipsAppMixin from snipskit.mqtt.dialogue import end-session # Use the assistant's language. i18n = importlib.import_module('translations.' + SnipsAppMixin().assistant['language']) CONFIGURATION_ENCODING_FORMAT = "utf-8" CONFIG_INI = "config.ini" MQTT_IP_ADDR = "localhost" MQTT_PORT = 1883 MQTT_ADDR = "{}:{}".format(MQTT_IP_ADDR, str(MQTT_PORT)) INTENT_ALL = "hermes/intent/#" class SnipsConfigParser(ConfigParser.SafeConfigParser): def to_dict(self): return {section: {option_name : option for option_name, option in self.items(section)} for section in self.sections()} def read_configuration_file(configuration_file):