Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional parameter parsing for HTML file name #3005

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,27 @@ def sig_term_handler():
logger.info("Got SIGTERM signal")
shutdown()

def process_html_filename(options) -> None:
num_users = options.num_users
spawn_rate = options.spawn_rate
run_time = options.run_time

option_mapping = {
"{u}": num_users,
"{r}": spawn_rate,
"{t}": run_time,
}

html_filename = options.html_file

for option_term, option_value in option_mapping.items():
html_filename = html_filename.replace(option_term, str(int(option_value)))

options.html_file = html_filename

def save_html_report():
html_report = get_html_report(environment, show_download_link=False)
process_html_filename(options)
logger.info("writing html report to file: %s", options.html_file)
with open(options.html_file, "w", encoding="utf-8") as file:
file.write(html_report)
Expand Down
Loading