mirror of
1
0
Fork 0

added 'suppressShellCmd' config option to allow only message display

This commit is contained in:
Vito Giarrusso 2017-07-26 19:03:47 +10:00
parent fe9ca6f5ed
commit a351063b3f
1 changed files with 10 additions and 1 deletions

View File

@ -18,16 +18,20 @@ class Shell(dotbot.Plugin):
def _process_commands(self, data):
success = True
suppress_shell_cmd = False
defaults = self._context.defaults().get('shell', {})
with open(os.devnull, 'w') as devnull:
for item in data:
stdin = stdout = stderr = devnull
suppress_shell_cmd = suppress_shell_cmd = False
if defaults.get('stdin', False) == True:
stdin = None
if defaults.get('stdout', False) == True:
stdout = None
if defaults.get('stderr', False) == True:
stderr = None
if defaults.get('suppressShellCmd', False) == True:
suppress_shell_cmd = True
if isinstance(item, dict):
cmd = item['command']
msg = item.get('description', None)
@ -37,6 +41,8 @@ class Shell(dotbot.Plugin):
stdout = None if item['stdout'] == True else devnull
if 'stderr' in item:
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):
cmd = item[0]
msg = item[1] if len(item) > 1 else None
@ -46,7 +52,10 @@ class Shell(dotbot.Plugin):
if msg is None:
self._log.lowinfo(cmd)
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')
ret = subprocess.call(cmd, shell=True, stdin=stdin, stdout=stdout,
stderr=stderr, cwd=self._context.base_directory(),