major search and replace from python to python3
[arvados.git] / doc / _includes / _run_md5sum_py.liquid
1 #!/usr/bin/env python3
2 {% comment %}
3 Copyright (C) The Arvados Authors. All rights reserved.
4
5 SPDX-License-Identifier: CC-BY-SA-3.0
6 {% endcomment %}
7
8 import arvados
9
10 # Automatically parallelize this job by running one task per file.
11 arvados.job_setup.one_task_per_input_file(if_sequence=0, and_end_task=True,
12                                           input_as_path=True)
13
14 # Get the input file for the task
15 input_file = arvados.get_task_param_mount('input')
16
17 # Run the external 'md5sum' program on the input file
18 stdoutdata, stderrdata = arvados.util.run_command(['md5sum', input_file])
19
20 # Save the standard output (stdoutdata) to "md5sum.txt" in the output collection
21 out = arvados.CollectionWriter()
22 with out.open('md5sum.txt') as out_file:
23     out_file.write(stdoutdata)
24 arvados.current_task().set_output(out.finish())