mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-09 17:34:16 +00:00
action with arguments for #59
This commit is contained in:
@@ -32,12 +32,23 @@ class Cmd:
|
||||
|
||||
class Action(Cmd):
|
||||
|
||||
def __init__(self, key, action, *args):
|
||||
super(Action, self).__init__(key, action)
|
||||
self.args = args
|
||||
|
||||
def execute(self):
|
||||
"""execute the action in the shell"""
|
||||
ret = 1
|
||||
self.log.sub('executing \"{}\"'.format(self.action))
|
||||
try:
|
||||
ret = subprocess.call(self.action, shell=True)
|
||||
cmd = self.action.format(*self.args)
|
||||
except IndexError:
|
||||
err = 'bad action: \"{}\"'.format(self.action)
|
||||
err += ' with \"{}\"'.format(self.args)
|
||||
self.log.warn(err)
|
||||
return False
|
||||
self.log.sub('executing \"{}\"'.format(cmd))
|
||||
try:
|
||||
ret = subprocess.call(cmd, shell=True)
|
||||
except KeyboardInterrupt:
|
||||
self.log.warn('action interrupted')
|
||||
return ret == 0
|
||||
|
||||
Reference in New Issue
Block a user