def push_remote_text_file(self, input_data=None, run=False, file_output=False):
"""
Push a text file to the current remote ECS cluster instance and optionally run it.
:param input_data: Input data to send. Either string or file.
:param run: Boolean that indicates if the text file should be run.
:param file_output: Boolean that indicates if the output should be saved.
:return: tuple - success, output
"""
if self.__is_or_has_file(input_data):
path, name = os.path.split(input_data.name)
else:
name = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
if run:
cmd = '"cat \> {}\;bash {}\;rm {}"'.format(name, name, name)
else:
cmd = '"cat \> {}"'.format(name)
with_output = True
if file_output:
with_output = NamedTemporaryFile(delete=False)
output_filename = with_output.name
success, output = self.ssh(command=cmd, with_output=with_output, input_data=input_data)
if file_output:
output = output_filename
return success, output
评论列表
文章目录