Writing Crunch scripts in Python

...

How to read your input file from the json template

...

How to write your file to a collection

...

How to run an external command

Usually this is most convenient:

import subprocess
foo = subprocess.check_output(['echo','foo'])

If the output is big, redirect it to a file:

import subprocess
with open('/tmp/foo', 'w') as outfile:
    subprocess.check_call(['head', '-c', '1234567', '/dev/urandom'], stdout=outfile)

How to create new tasks per input file in a collection

...

Where to put temporary files

...

How to write data directly to Keep with native Python code

...