mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Catch TypeErrors in timed_subprocess
This allows us to pass lists of args to cmd.* without having to do type checking beforehand to make sure they're lists.
This commit is contained in:
parent
991bbf63fe
commit
cd35df5ff8
1 changed files with 14 additions and 2 deletions
|
@ -5,6 +5,7 @@ from __future__ import absolute_import
|
|||
import subprocess
|
||||
import threading
|
||||
import salt.exceptions
|
||||
from salt.ext import six
|
||||
|
||||
|
||||
class TimedProc(object):
|
||||
|
@ -13,7 +14,6 @@ class TimedProc(object):
|
|||
'''
|
||||
def __init__(self, args, **kwargs):
|
||||
|
||||
self.command = args
|
||||
self.stdin = kwargs.pop('stdin', None)
|
||||
if self.stdin is not None:
|
||||
# Translate a newline submitted as '\n' on the CLI to an actual
|
||||
|
@ -22,7 +22,19 @@ class TimedProc(object):
|
|||
kwargs['stdin'] = subprocess.PIPE
|
||||
self.with_communicate = kwargs.pop('with_communicate', True)
|
||||
|
||||
self.process = subprocess.Popen(args, **kwargs)
|
||||
try:
|
||||
self.process = subprocess.Popen(args, **kwargs)
|
||||
except TypeError:
|
||||
str_args = []
|
||||
for arg in args:
|
||||
if not isinstance(arg, six.string_types):
|
||||
str_args.append(str(arg))
|
||||
else:
|
||||
str_args.append(arg)
|
||||
args = str_args
|
||||
self.process = subprocess.Popen(args, **kwargs)
|
||||
self.command = args
|
||||
|
||||
|
||||
def wait(self, timeout=None):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue