added 'suppressShellCmd' config option to allow only message display
This commit is contained in:
parent
fe9ca6f5ed
commit
a351063b3f
|
@ -18,16 +18,20 @@ class Shell(dotbot.Plugin):
|
||||||
|
|
||||||
def _process_commands(self, data):
|
def _process_commands(self, data):
|
||||||
success = True
|
success = True
|
||||||
|
suppress_shell_cmd = False
|
||||||
defaults = self._context.defaults().get('shell', {})
|
defaults = self._context.defaults().get('shell', {})
|
||||||
with open(os.devnull, 'w') as devnull:
|
with open(os.devnull, 'w') as devnull:
|
||||||
for item in data:
|
for item in data:
|
||||||
stdin = stdout = stderr = devnull
|
stdin = stdout = stderr = devnull
|
||||||
|
suppress_shell_cmd = suppress_shell_cmd = False
|
||||||
if defaults.get('stdin', False) == True:
|
if defaults.get('stdin', False) == True:
|
||||||
stdin = None
|
stdin = None
|
||||||
if defaults.get('stdout', False) == True:
|
if defaults.get('stdout', False) == True:
|
||||||
stdout = None
|
stdout = None
|
||||||
if defaults.get('stderr', False) == True:
|
if defaults.get('stderr', False) == True:
|
||||||
stderr = None
|
stderr = None
|
||||||
|
if defaults.get('suppressShellCmd', False) == True:
|
||||||
|
suppress_shell_cmd = True
|
||||||
if isinstance(item, dict):
|
if isinstance(item, dict):
|
||||||
cmd = item['command']
|
cmd = item['command']
|
||||||
msg = item.get('description', None)
|
msg = item.get('description', None)
|
||||||
|
@ -37,6 +41,8 @@ class Shell(dotbot.Plugin):
|
||||||
stdout = None if item['stdout'] == True else devnull
|
stdout = None if item['stdout'] == True else devnull
|
||||||
if 'stderr' in item:
|
if 'stderr' in item:
|
||||||
stderr = None if item['stderr'] == True else devnull
|
stderr = None if item['stderr'] == True else devnull
|
||||||
|
if 'suppressShellCmd' in item:
|
||||||
|
suppress_shell_cmd = True if item['suppressShellCmd'] == True else False
|
||||||
elif isinstance(item, list):
|
elif isinstance(item, list):
|
||||||
cmd = item[0]
|
cmd = item[0]
|
||||||
msg = item[1] if len(item) > 1 else None
|
msg = item[1] if len(item) > 1 else None
|
||||||
|
@ -46,7 +52,10 @@ class Shell(dotbot.Plugin):
|
||||||
if msg is None:
|
if msg is None:
|
||||||
self._log.lowinfo(cmd)
|
self._log.lowinfo(cmd)
|
||||||
else:
|
else:
|
||||||
self._log.lowinfo('%s [%s]' % (msg, cmd))
|
if suppress_shell_cmd is False:
|
||||||
|
self._log.lowinfo('%s [%s]' % (msg, cmd))
|
||||||
|
else:
|
||||||
|
self._log.lowinfo('%s' % (msg))
|
||||||
executable = os.environ.get('SHELL')
|
executable = os.environ.get('SHELL')
|
||||||
ret = subprocess.call(cmd, shell=True, stdin=stdin, stdout=stdout,
|
ret = subprocess.call(cmd, shell=True, stdin=stdin, stdout=stdout,
|
||||||
stderr=stderr, cwd=self._context.base_directory(),
|
stderr=stderr, cwd=self._context.base_directory(),
|
||||||
|
|
Loading…
Reference in a new issue