This commit is contained in:
flaskfarm
2022-10-13 01:36:15 +09:00
parent f4a8844024
commit 09b57d87b9

View File

@@ -22,9 +22,10 @@ class SupportSubprocess(object):
# 2021-10-25 # 2021-10-25
# timeout 적용 # timeout 적용
@classmethod @classmethod
def execute_command_return(cls, command, format=None, force_log=False, shell=False, env=None, timeout=None, uid=0, gid=0): def execute_command_return(cls, command, format=None, log=False, shell=False, env=None, timeout=None, uid=0, gid=0):
try: try:
logger.debug(f"execute_command_return : {' '.join(command)}")
if platform.system() == 'Windows': if platform.system() == 'Windows':
tmp = [] tmp = []
if type(command) == type([]): if type(command) == type([]):
@@ -39,7 +40,8 @@ class SupportSubprocess(object):
if platform.system() == 'Windows': if platform.system() == 'Windows':
process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=shell, env=env, encoding='utf8') process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=shell, env=env, encoding='utf8')
else: else:
process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=shell, env=env, preexec_fn=demote(uid, gid), encoding='utf8') #process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=shell, env=env, preexec_fn=demote(uid, gid), encoding='utf8')
process = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=shell, env=env, encoding='utf8')
new_ret = {'status':'finish', 'log':None} new_ret = {'status':'finish', 'log':None}
@@ -57,7 +59,7 @@ class SupportSubprocess(object):
with process.stdout: with process.stdout:
for line in iter(process.stdout.readline, iter_arg): for line in iter(process.stdout.readline, iter_arg):
ret.append(line.strip()) ret.append(line.strip())
if force_log: if log:
logger.debug(ret[-1]) logger.debug(ret[-1])
if format is None: if format is None: