1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/source4/scripting/bin/gen_output.py
Joe Guo a19d5bd771 PY3: change shebang to python3 in source4/scripting/bin dir
Samba default python is 3 now.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Noel Power <npower@samba.org>
2018-12-14 14:40:20 +01:00

54 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python3
# Copyright (C) Catalyst IT Ltd. 2017
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
A data generator to help tests.
Generate large output to stdout by repeating input data.
Usage:
python gen_output.py --data @ --repeat 1024 --retcode 1
The above command will output @ x 1024 (1K) and exit with 1.
"""
import sys
import argparse
parser = argparse.ArgumentParser(description='Generate output data')
parser.add_argument(
'--data', type=str, default='$',
help='Characters used to generate data by repeating them'
)
parser.add_argument(
'--repeat', type=int, default=1024 * 1024,
help='How many times to repeat the data'
)
parser.add_argument(
'--retcode', type=int, default=0,
help='Specify the exit code for this script'
)
args = parser.parse_args()
sys.stdout.write(args.data * args.repeat)
sys.exit(args.retcode)