Skip to content

Commit

Permalink
fix: alias overwrite ... (#18)
Browse files Browse the repository at this point in the history
* feat: add dialog

* fix: alias overwrite 🤦

* fix: shell args
  • Loading branch information
JarbasAl authored Nov 17, 2024
1 parent 2e46196 commit 7d6ef63
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
19 changes: 11 additions & 8 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pwd import getpwnam
import os
import shlex
import subprocess
from pwd import getpwnam

from ovos_utils.log import LOG
from ovos_workshop.skills import OVOSSkill
from ovos_workshop.intents import IntentBuilder

from ovos_workshop.decorators import intent_handler
from ovos_workshop.intents import IntentBuilder
from ovos_workshop.skills import OVOSSkill


def set_user(uid, gid):
Expand All @@ -31,10 +33,10 @@ def set_user(uid, gid):
class CmdSkill(OVOSSkill):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.uid = None
self.gid = None
self.alias = {}
super().__init__(*args, **kwargs)

def initialize(self):
user = self.settings.get('user')
Expand All @@ -52,11 +54,12 @@ def initialize(self):
@intent_handler(IntentBuilder('RunScriptCommandIntent')
.require('Script').require('Run'))
def run(self, message):
self.acknowledge()
script = message.data.get('Script')
script = self.alias.get(script, script)
alias = message.data.get('Script')
self.speak_dialog("running", {"alias": alias})
script = self.alias[alias]
LOG.info(f"alias: {alias} | command: {script}")
shell = self.settings.get('shell', True)
args = script.split(' ') if shell else script
args = script if shell else shlex.split(script)
try:
LOG.info(f'Running {args}')
if self.uid and self.gid:
Expand Down
1 change: 1 addition & 0 deletions locale/en-us/running.dialog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
running {alias} (command|script)
5 changes: 5 additions & 0 deletions translations/en-us/dialogs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"running.dialog": [
"running {alias} (command|script)"
]
}

0 comments on commit 7d6ef63

Please sign in to comment.