예제 #1
0
 def _queue(self, message):
     if self.current:
         LOG('Queuing Track')
         tracks = message.data['tracks']
         self.current.add_list(tracks)
     else:
         self._play(message)
예제 #2
0
    def echo(message):
        global _log_all_bus_messages
        try:
            msg = json.loads(message)
            msg_type = msg.get("type", "")
            # Whitelist match beginning of message
            # i.e 'mycroft.audio.service' will allow the message
            # 'mycroft.audio.service.play' for example
            if whitelist and not any(
                [msg_type.startswith(e) for e in whitelist]):
                return

            if blacklist and msg_type in blacklist:
                return

            if msg_type == "mycroft.debug.log":
                # Respond to requests to adjust the logger settings
                lvl = msg["data"].get("level", "").upper()
                if lvl in ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]:
                    LOG.level = lvl
                    LOG(name).info("Changing log level to: {}".format(lvl))
                    try:
                        logging.getLogger().setLevel(lvl)
                        logging.getLogger('urllib3').setLevel(lvl)
                    except Exception:
                        pass  # We don't really care about if this fails...
                else:
                    LOG(name).info("Invalid level provided: {}".format(lvl))

                # Allow enable/disable of messagebus traffic
                log_bus = msg["data"].get("bus", None)
                if log_bus is not None:
                    LOG(name).info("Bus logging: {}".format(log_bus))
                    _log_all_bus_messages = log_bus
            elif msg_type == "registration":
                # do not log tokens from registration messages
                msg["data"]["token"] = None
                message = json.dumps(msg)
        except Exception as e:
            LOG.info("Error: {}".format(repr(e)), exc_info=True)

        if _log_all_bus_messages:
            # Listen for messages and echo them for logging
            LOG(name).info("BUS: {}".format(message))
    def __init__(self, mode='tts'):
        super(PlagueisSkillContext, self).__init__(name='PlagueisSkill')
        self.darkside = False
        self.started = False
        if mode == 'wav':
            self.wav_mode = True
        else:
            self.wav_mode = False

        LOG("PlagueisSKill").debug("Darth Plagueis skill loaded")
예제 #4
0
    def __init__(self, mode='tts'):
        super(WalkSkillContext, self).__init__(name='WalkSkill')
        self.darkside = False
        self.started = False
        if mode=='wav':
            self.wav_mode = True
        else:
            self.wav_mode = False

        LOG("WalkSkill").debug("Walking skill loaded")
예제 #5
0
    def _echo(message):
        try:
            _message = json.loads(message)

            if _message.get("type") in ignore_logs:
                return

            if _message.get("type") == "registration":
                # do not log tokens from registration messages
                _message["data"]["token"] = None
            message = json.dumps(_message)
        except:
            pass
        LOG('SKILLS').debug(message)
예제 #6
0
    def echo(message):
        global _log_all_bus_messages
        try:
            msg = json.loads(message)

            if whitelist and msg.get("type") not in whitelist:
                return

            if blacklist and msg.get("type") in blacklist:
                return

            if msg.get("type") == "mycroft.debug.log":
                # Respond to requests to adjust the logger settings
                lvl = msg["data"].get("level", "").upper()
                if lvl in ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]:
                    LOG.level = lvl
                    LOG(name).info("Changing log level to: {}".format(lvl))
                    try:
                        logging.getLogger('urllib3').setLevel(lvl)
                    except Exception:
                        pass  # We don't really care about if this fails...

                # Allow enable/disable of messagebus traffic
                log_bus = msg["data"].get("bus", None)
                if log_bus is not None:
                    LOG(name).info("Bus logging: " + str(log_bus))
                    _log_all_bus_messages = log_bus
            elif msg.get("type") == "registration":
                # do not log tokens from registration messages
                msg["data"]["token"] = None
                message = json.dumps(msg)
        except Exception:
            pass

        if _log_all_bus_messages:
            # Listen for messages and echo them for logging
            LOG(name).debug(message)
예제 #7
0
    def echo(message):
        """Listen for messages and echo them for logging"""
        try:
            js_msg = json.loads(message)

            if whitelist and js_msg.get("type") not in whitelist:
                return

            if blacklist and js_msg.get("type") in blacklist:
                return

            if js_msg.get("type") == "registration":
                # do not log tokens from registration messages
                js_msg["data"]["token"] = None
                message = json.dumps(js_msg)
        except Exception:
            pass
        LOG(name).debug(message)
예제 #8
0
from adapt.intent import IntentBuilder
from mycroft import MycroftSkill, intent_file_handler
from mycroft.util.log import LOG
import urllib, urllib.request, json, random, re
from urllib.request import Request

__author__ = 'krisgesling'
LOGGER = LOG(__name__)

class TronaldDump(MycroftSkill):
    def __init__(self):
        MycroftSkill.__init__(self)

    @intent_file_handler('dump.tronald.intent')
    def handle_dump_tronald(self, message):
        topic = message.data['topic']
        urlParams = { 'query': topic }
        apiUrl = "https://api.tronalddump.io/search/quote?%s" % urllib.parse.urlencode(urlParams)
        try:
            with urllib.request.urlopen(Request(apiUrl, headers={'User-Agent': 'Mozilla/5.0'})) as url:
                result = json.loads(url.read().decode())
                if result['count'] == 0:
                    self.speak_dialog('no.result', {'topic': topic})
                else:
                    i = random.randint(0, result['count'] - 1)
                    rawQuote = result['_embedded']['quotes'][i]['value']
                    speakingQuote = re.sub(r'https?:\/\/.*\s?', '', rawQuote)
                    self.speak_dialog('dump.tronald', {'quote': speakingQuote})
        except urllib.error.HTTPError as e:
            self.speak_dialog('http.error')
        except urllib.error.URLError as e:
예제 #9
0
 def test_logging():
     LOG.debug('testing debug')
     LOG.info('testing info')
     LOG.warning('testing warning')
     LOG.error('testing error')
     LOG('testing custom').debug('test')
    def __init__(self, mode='tts'):
        super(WalkSkillContext, self).__init__(name='WalkSkill')
        self.started = False

        LOG("WalkSkill").debug("Walking skill loaded")