reading script dir
This commit is contained in:
parent
bb81a938e6
commit
3d8d761cee
20
__init__.py
20
__init__.py
|
@ -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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
I couldn't find a script named {{script}}.
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue