reading script dir

This commit is contained in:
Rudis Muiznieks 2022-02-08 14:29:23 -06:00
parent bb81a938e6
commit 3d8d761cee
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
3 changed files with 18 additions and 7 deletions

View File

@ -1,24 +1,34 @@
import os
from mycroft import MycroftSkill, intent_handler
class RunScriptSkill(MycroftSkill):
def __init__(self):
super().__init__()
self.script_dir = None
self.scripts = []
def initialize(self):
self.settings_change_callback = self.on_settings_changed
self.on_settings_changed()
def on_settings_changed(self):
script_dir = self.settings.get('script_dir')
self.read_scripts_dir(script_dir)
self.script_dir = self.settings.get('script_dir')
self.read_scripts_dir()
def read_script_dir(self, script_dir):
pass
def read_script_dir(self):
if os.isdir(self.script_dir):
self.scripts = os.listdir(script_dir)
else:
self.log.critical("The script_dir directory does not exist or can't be read")
self.scripts = []
@intent_handler('RunScript.intent')
def handle_run_script_intent(self, msg=None):
script = msg.data.get('script', None)
self.speak_dialog('Running', {'script': script})
if script in self.scripts:
self.speak_dialog('Running', {'script': script})
else:
self.speak_dialog('NotFound', {'script': script})
def stop(self):
pass

View File

@ -0,0 +1 @@
I couldn't find a script named {{script}}.

View File

@ -1,2 +1,2 @@
(run|execute) (the|my|your) {script} script
(run|execute) {script} script
(run|execute) (the|my|your) {script} (script|program)
(run|execute) {script} (script|program)