Skip to content

Commit

Permalink
Rename base-path to web-base-path
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbaldwin44 committed Nov 4, 2024
1 parent 5006d47 commit d7d500f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions examples/web_ui_auth/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def load_user(username):
@events.init.add_listener
def locust_init(environment, **_kwargs):
if environment.web_ui:
auth_blueprint = Blueprint("auth", "web_ui_auth", url_prefix=environment.parsed_options.base_path)
auth_blueprint = Blueprint("auth", "web_ui_auth", url_prefix=environment.parsed_options.web_base_path)

environment.web_ui.login_manager.user_loader(load_user)

environment.web_ui.app.config["SECRET_KEY"] = os.getenv("FLASK_SECRET_KEY")

environment.web_ui.auth_args = {
"username_password_callback": f"{environment.parsed_options.base_path}/login_submit",
"username_password_callback": f"{environment.parsed_options.web_base_path}/login_submit",
"auth_providers": [
{
"label": "Github",
Expand Down
4 changes: 2 additions & 2 deletions examples/web_ui_auth/custom_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def load_user(user_id):
@events.init.add_listener
def locust_init(environment, **_kwargs):
if environment.web_ui:
auth_blueprint = Blueprint("auth", "web_ui_auth", url_prefix=environment.parsed_options.base_path)
auth_blueprint = Blueprint("auth", "web_ui_auth", url_prefix=environment.parsed_options.web_base_path)

environment.web_ui.login_manager.user_loader(load_user)

Expand Down Expand Up @@ -69,7 +69,7 @@ def locust_init(environment, **_kwargs):
"is_secret": True,
},
],
"callback_url": f"{environment.parsed_options.base_path}/login_submit",
"callback_url": f"{environment.parsed_options.web_base_path}/login_submit",
"submit_button_text": "Submit",
},
}
Expand Down
4 changes: 2 additions & 2 deletions locust/argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,11 @@ def setup_parser_arguments(parser):
)

web_ui_group.add_argument(
"--base-path",
"--web-base-path",
type=str,
default="",
help="Base path for the web interface (e.g., '/locust'). Default is empty (root path).",
env_var="BASE_PATH",
env_var="LOCUST_web_base_path",
)

tag_group = parser.add_argument_group(
Expand Down
4 changes: 2 additions & 2 deletions locust/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def create_web_ui(
self,
host="",
port=8089,
base_path: str | None = None,
web_base_path: str | None = None,
web_login: bool = False,
tls_cert: str | None = None,
tls_key: str | None = None,
Expand Down Expand Up @@ -200,7 +200,7 @@ def create_web_ui(
delayed_start=delayed_start,
userclass_picker_is_active=userclass_picker_is_active,
build_path=build_path,
base_path=base_path,
web_base_path=web_base_path,
)
return self.web_ui

Expand Down
10 changes: 5 additions & 5 deletions locust/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ def ensure_user_class_name(config):
try:
runner = environment.create_worker_runner(options.master_host, options.master_port)
logger.debug(
"Connected to locust master: %s:%s%s", options.master_host, options.master_port, options.base_path
"Connected to locust master: %s:%s%s", options.master_host, options.master_port, options.web_base_path
)
except OSError as e:
logger.error("Failed to connect to the Locust master: %s", e)
Expand Down Expand Up @@ -498,21 +498,21 @@ def ensure_user_class_name(config):
else:
web_host = options.web_host
if web_host:
logger.info(f"Starting web interface at {protocol}://{web_host}:{options.web_port}{options.base_path}")
logger.info(f"Starting web interface at {protocol}://{web_host}:{options.web_port}{options.web_base_path}")
if options.web_host_display_name:
logger.info(f"Starting web interface at {options.web_host_display_name}")
else:
if os.name == "nt":
logger.info(
f"Starting web interface at {protocol}://localhost:{options.web_port}{options.base_path} (accepting connections from all network interfaces)"
f"Starting web interface at {protocol}://localhost:{options.web_port}{options.web_base_path} (accepting connections from all network interfaces)"
)
else:
logger.info(f"Starting web interface at {protocol}://0.0.0.0:{options.web_port}{options.base_path}")
logger.info(f"Starting web interface at {protocol}://0.0.0.0:{options.web_port}{options.web_base_path}")

web_ui = environment.create_web_ui(
host=web_host,
port=options.web_port,
base_path=options.base_path,
web_base_path=options.web_base_path,
web_login=options.web_login,
tls_cert=options.tls_cert,
tls_key=options.tls_key,
Expand Down
4 changes: 2 additions & 2 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,11 +1475,11 @@ def connect_to_master(self):
if not success:
if self.retry < 3:
logger.debug(
f"Failed to connect to master {self.master_host}:{self.master_port}{self.environment.parsed_options.base_path}, retry {self.retry}/{CONNECT_RETRY_COUNT}."
f"Failed to connect to master {self.master_host}:{self.master_port}{self.environment.parsed_options.web_base_path}, retry {self.retry}/{CONNECT_RETRY_COUNT}."
)
else:
logger.warning(
f"Failed to connect to master {self.master_host}:{self.master_port}{self.environment.parsed_options.base_path}, retry {self.retry}/{CONNECT_RETRY_COUNT}."
f"Failed to connect to master {self.master_host}:{self.master_port}{self.environment.parsed_options.web_base_path}, retry {self.retry}/{CONNECT_RETRY_COUNT}."
)
if self.retry > CONNECT_RETRY_COUNT:
raise ConnectionError()
Expand Down
4 changes: 2 additions & 2 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(
environment: Environment,
host: str,
port: int,
base_path: str | None = None,
web_base_path: str | None = None,
web_login: bool = False,
tls_cert: str | None = None,
tls_key: str | None = None,
Expand Down Expand Up @@ -164,7 +164,7 @@ def __init__(
self.app.template_folder = build_path or DEFAULT_BUILD_PATH
self.app.static_url_path = "/assets/"

app_blueprint = Blueprint("locust", __name__, url_prefix=base_path)
app_blueprint = Blueprint("locust", __name__, url_prefix=web_base_path)
# ensures static js files work on Windows
mimetypes.add_type("application/javascript", ".js")
if self.web_login:
Expand Down

0 comments on commit d7d500f

Please sign in to comment.