This commit is contained in:
flaskfarm
2022-10-21 01:41:49 +09:00
parent 56419a8355
commit 2e27ae8f72
20 changed files with 603 additions and 143 deletions

View File

@@ -53,19 +53,6 @@ class SupportFile(object):
return False
@classmethod
def text_for_filename(cls, text):
#text = text.replace('/', '')
@@ -94,6 +81,83 @@ class SupportFile(object):
@classmethod

View File

@@ -19,6 +19,19 @@ def demote(user_uid, user_gid):
class SupportSubprocess(object):
@classmethod
def command_for_windows(cls, command: list) -> str or list:
if platform.system() == 'Windows':
tmp = []
if type(command) == type([]):
for x in command:
if x.find(' ') == -1:
tmp.append(x)
else:
tmp.append(f'"{x}"')
command = ' '.join(tmp)
return command
# 2021-10-25
# timeout 적용
@classmethod
@@ -26,15 +39,7 @@ class SupportSubprocess(object):
try:
logger.debug(f"execute_command_return : {' '.join(command)}")
if platform.system() == 'Windows':
tmp = []
if type(command) == type([]):
for x in command:
if x.find(' ') == -1:
tmp.append(x)
else:
tmp.append(f'"{x}"')
command = ' '.join(tmp)
command = cls.command_for_windows(command)
iter_arg = ''
if platform.system() == 'Windows':
@@ -119,16 +124,7 @@ class SupportSubprocess(object):
def __execute_thread_function(self):
try:
if platform.system() == 'Windows':
tmp = []
if type(self.command) == type([]):
for x in self.command:
if x.find(' ') == -1:
tmp.append(x)
else:
tmp.append(f'"{x}"')
self.command = ' '.join(tmp)
self.command = self.command_for_windows(self.command)
logger.debug(f"{self.command=}")
if platform.system() == 'Windows':
self.process = subprocess.Popen(self.command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, shell=self.shell, env=self.env, encoding='utf8', bufsize=0)
@@ -141,7 +137,11 @@ class SupportSubprocess(object):
self.__start_communicate()
self.__start_send_callback()
if self.process is not None:
self.process.wait()
if self.timeout != None:
self.process.wait(timeout=self.timeout)
self.process_close()
else:
self.process.wait()
logger.info(f"{self.command} END")
except Exception as e:
logger.error(f'Exception:{str(e)}')