INNER CODE UNIT · Python
execute_command_chunks
fyoorer/ShadowClone · shadowclone.py:106
def execute_command_chunks(obj, command, nosplit, bucket_name, scan_id, storage):
from invoke import run
import uuid
import os
if not command: #hopefully we never go into this
return "LITHOPS ERROR! Command was not received by the cloud function! Try re-running the same command."
data = obj.data_stream.read()
with open('/tmp/infile','w') as infile:
for line in data.splitlines():
infile.write(line.decode("UTF-8")+'\n')
output_file_rnd = str(uuid.uuid4())
outfile = "/tmp/"+output_file_rnd
command = command.replace('{INPUT}', '/tmp/infile')
command = command.replace('{OUTPUT}', outfile)