Skip to content

Commit f32ada5

Browse files
author
ktchani3
committed
Add optional parameter parsing for HTML file name
1 parent 35b07bb commit f32ada5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

locust/main.py

+19
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,27 @@ def sig_term_handler():
705705
logger.info("Got SIGTERM signal")
706706
shutdown()
707707

708+
def process_html_filename(options) -> None:
709+
num_users = options.num_users
710+
spawn_rate = options.spawn_rate
711+
run_time = options.run_time
712+
713+
option_mapping = {
714+
"{u}": num_users,
715+
"{r}": spawn_rate,
716+
"{t}": run_time,
717+
}
718+
719+
html_filename = options.html_file
720+
721+
for option_term, option_value in option_mapping.items():
722+
html_filename = html_filename.replace(option_term, str(int(option_value)))
723+
724+
options.html_file = html_filename
725+
708726
def save_html_report():
709727
html_report = get_html_report(environment, show_download_link=False)
728+
process_html_filename(options)
710729
logger.info("writing html report to file: %s", options.html_file)
711730
with open(options.html_file, "w", encoding="utf-8") as file:
712731
file.write(html_report)

0 commit comments

Comments
 (0)