forked from MycroftAI/mycroft-core
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
567 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from ovos_workshop.decorators import killable_intent | ||
from ovos_workshop.skills.ovos import OVOSSkill | ||
from mycroft.skills import intent_file_handler | ||
from time import sleep | ||
|
||
|
||
class TestAbortSkill(OVOSSkill): | ||
""" | ||
send "mycroft.skills.abort_question" and confirm only get_response is aborted | ||
send "mycroft.skills.abort_execution" and confirm the full intent is aborted, except intent3 | ||
send "my.own.abort.msg" and confirm intent3 is aborted | ||
say "stop" and confirm all intents are aborted | ||
""" | ||
def initialize(self): | ||
self.stop_called = False | ||
self._converse = False | ||
self.add_event(f"{self.skill_id}.converse_enable", self.handle_converse_on) | ||
self.add_event(f"{self.skill_id}.converse_disable", self.handle_converse_off) | ||
|
||
@intent_file_handler("converse_on.intent") | ||
def handle_converse_on(self, message): | ||
self._converse = True | ||
self.speak("on") | ||
|
||
@intent_file_handler("converse_off.intent") | ||
def handle_converse_off(self, message): | ||
self._converse = False | ||
self.speak("off") | ||
|
||
def handle_intent_aborted(self): | ||
self.speak("I am dead") | ||
|
||
@intent_file_handler("test_get_response.intent") | ||
def handle_test_get_response(self, message): | ||
ans = self.get_response("get") | ||
self.speak(ans) | ||
|
||
@killable_intent(callback=handle_intent_aborted) | ||
@intent_file_handler("test.intent") | ||
def handle_test_abort_intent(self, message): | ||
self.stop_called = False | ||
self.my_special_var = "changed" | ||
while True: | ||
sleep(1) | ||
self.speak("still here") | ||
|
||
@intent_file_handler("test2.intent") | ||
@killable_intent(callback=handle_intent_aborted) | ||
def handle_test_get_response_intent(self, message): | ||
self.stop_called = False | ||
self.my_special_var = "CHANGED" | ||
ans = self.get_response("question", num_retries=99999) | ||
self.log.debug("get_response returned: " + str(ans)) | ||
if ans is None: | ||
self.speak("question aborted") | ||
|
||
@killable_intent(msg="my.own.abort.msg", callback=handle_intent_aborted) | ||
@intent_file_handler("test3.intent") | ||
def handle_test_msg_intent(self, message): | ||
self.stop_called = False | ||
if self.my_special_var != "default": | ||
self.speak("someone forgot to cleanup") | ||
while True: | ||
sleep(1) | ||
self.speak("you can't abort me") | ||
|
||
def stop(self): | ||
self.stop_called = True | ||
|
||
def converse(self, message): | ||
return self._converse |
1 change: 1 addition & 0 deletions
1
test/end2end/session/skill-converse_test/locale/en-us/converse_off.intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
no |
1 change: 1 addition & 0 deletions
1
test/end2end/session/skill-converse_test/locale/en-us/converse_on.intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
yes |
1 change: 1 addition & 0 deletions
1
test/end2end/session/skill-converse_test/locale/en-us/get.dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
give me an answer |
1 change: 1 addition & 0 deletions
1
test/end2end/session/skill-converse_test/locale/en-us/question.dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this is a question |
1 change: 1 addition & 0 deletions
1
test/end2end/session/skill-converse_test/locale/en-us/test.intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test |
1 change: 1 addition & 0 deletions
1
test/end2end/session/skill-converse_test/locale/en-us/test2.intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test again |
1 change: 1 addition & 0 deletions
1
test/end2end/session/skill-converse_test/locale/en-us/test3.intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
one more test |
1 change: 1 addition & 0 deletions
1
test/end2end/session/skill-converse_test/locale/en-us/test_get_response.intent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test get response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
from setuptools import setup | ||
from os import getenv, path, walk | ||
|
||
|
||
def find_resource_files(): | ||
resource_base_dirs = ("locale", "ui", "vocab", "dialog", "regex") | ||
base_dir = path.dirname(__file__) | ||
package_data = ["skill.json"] | ||
for res in resource_base_dirs: | ||
if path.isdir(path.join(base_dir, res)): | ||
for (directory, _, files) in walk(path.join(base_dir, res)): | ||
if files: | ||
package_data.append( | ||
path.join(directory.replace(base_dir, "").lstrip('/'), | ||
'*')) | ||
return package_data | ||
|
||
|
||
# skill_id=package_name:SkillClass | ||
PLUGIN_ENTRY_POINT = 'ovos-tskill-abort.openvoiceos=ovos_tskill_abort:TestAbortSkill' | ||
|
||
setup( | ||
# this is the package name that goes on pip | ||
name='ovos-tskill-abort', | ||
version='0.0.1', | ||
description='this is a OVOS test skill for the killable_intents decorator', | ||
url='https://github.com/OpenVoiceOS/skill-abort-test', | ||
author='JarbasAi', | ||
author_email='[email protected]', | ||
license='Apache-2.0', | ||
package_dir={"ovos_tskill_abort": ""}, | ||
package_data={'ovos_tskill_abort': find_resource_files()}, | ||
packages=['ovos_tskill_abort'], | ||
include_package_data=True, | ||
install_requires=["ovos-workshop"], | ||
keywords='ovos skill plugin', | ||
entry_points={'ovos.plugin.skill': PLUGIN_ENTRY_POINT} | ||
) |
Oops, something went wrong.