locust 2.37.4.dev1__py3-none-any.whl → 2.37.5.dev6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
locust/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '2.37.4.dev1'
21
- __version_tuple__ = version_tuple = (2, 37, 4, 'dev1')
20
+ __version__ = version = '2.37.5.dev6'
21
+ __version_tuple__ = version_tuple = (2, 37, 5, 'dev6')
locust/argument_parser.py CHANGED
@@ -4,6 +4,7 @@ import locust
4
4
  from locust import runners
5
5
  from locust.rpc import Message, zmqrpc
6
6
 
7
+ import argparse
7
8
  import ast
8
9
  import atexit
9
10
  import json
@@ -283,25 +284,7 @@ def download_locustfile_from_master(master_host: str, master_port: int) -> str:
283
284
  return msg.data.get("locustfiles", [])
284
285
 
285
286
 
286
- def parse_locustfiles_from_master(locustfile_sources) -> list[str]:
287
- locustfiles = []
288
-
289
- for source in locustfile_sources:
290
- if "contents" in source:
291
- filename = source["filename"]
292
- file_contents = source["contents"]
293
-
294
- with open(os.path.join(tempfile.gettempdir(), filename), "w", encoding="utf-8") as locustfile:
295
- locustfile.write(file_contents)
296
-
297
- locustfiles.append(locustfile.name)
298
- else:
299
- locustfiles.append(source)
300
-
301
- return locustfiles
302
-
303
-
304
- def parse_locustfile_option(args=None) -> list[str]:
287
+ def parse_locustfile_option(args=None) -> tuple[argparse.Namespace, list[str]]:
305
288
  """
306
289
  Construct a command line parser that is only used to parse the -f argument so that we can
307
290
  import the test scripts in case any of them adds additional command line arguments to the
@@ -346,38 +329,51 @@ def parse_locustfile_option(args=None) -> list[str]:
346
329
  env_var="LOCUST_MASTER_NODE_PORT",
347
330
  )
348
331
 
349
- options, _ = parser.parse_known_args(args=args)
332
+ options, unknown = parser.parse_known_args(args=args)
350
333
 
351
334
  if options.help or options.version:
352
335
  # if --help or --version is specified we'll call parse_options which will print the help/version message
353
336
  parse_options(args=args)
354
337
 
338
+ return (options, unknown)
339
+
340
+
341
+ def get_locustfiles_locally(options):
355
342
  if options.locustfile == "-":
356
- if not options.worker:
357
- sys.stderr.write(
358
- "locustfile was set to '-' (meaning to download from master) but --worker was not specified.\n"
359
- )
360
- sys.exit(1)
361
- # having this in argument_parser module is a bit weird, but it needs to be done early
362
- locustfile_sources = download_locustfile_from_master(options.master_host, options.master_port)
363
- locustfile_list = parse_locustfiles_from_master(locustfile_sources)
343
+ locustfile_list = retrieve_locustfiles_from_master(options)
364
344
  else:
365
345
  locustfile_list = [f.strip() for f in options.locustfile.split(",")]
366
346
 
367
- parsed_paths = parse_locustfile_paths(locustfile_list)
347
+ return parse_locustfile_paths(locustfile_list)
348
+
368
349
 
369
- if not parsed_paths:
370
- note_about_file_endings = ""
371
- user_friendly_locustfile_name = options.locustfile
350
+ def parse_locustfiles_from_master(locustfile_sources) -> list[str]:
351
+ locustfiles = []
372
352
 
373
- if not options.locustfile.endswith(".py"):
374
- note_about_file_endings = "Ensure your locustfile ends with '.py' or is a directory with parsed_paths. "
353
+ for source in locustfile_sources:
354
+ if "contents" in source:
355
+ filename = source["filename"]
356
+ file_contents = source["contents"]
357
+
358
+ with open(os.path.join(tempfile.gettempdir(), filename), "w", encoding="utf-8") as locustfile:
359
+ locustfile.write(file_contents)
360
+
361
+ locustfiles.append(locustfile.name)
362
+ else:
363
+ locustfiles.append(source)
364
+
365
+ return locustfiles
366
+
367
+
368
+ def retrieve_locustfiles_from_master(options) -> list[str]:
369
+ if not options.worker:
375
370
  sys.stderr.write(
376
- f"Could not find '{user_friendly_locustfile_name}'. {note_about_file_endings}See --help for available options.\n"
371
+ "locustfile was set to '-' (meaning to download from master) but --worker was not specified.\n"
377
372
  )
378
373
  sys.exit(1)
379
-
380
- return parsed_paths
374
+ # having this in argument_parser module is a bit weird, but it needs to be done early
375
+ locustfile_sources = download_locustfile_from_master(options.master_host, options.master_port)
376
+ return parse_locustfiles_from_master(locustfile_sources)
381
377
 
382
378
 
383
379
  # A hack for setting up an action that raises ArgumentError with configurable error messages.
locust/main.py CHANGED
@@ -20,7 +20,11 @@ from typing import TYPE_CHECKING
20
20
  import gevent
21
21
 
22
22
  from . import log, stats
23
- from .argument_parser import parse_locustfile_option, parse_options
23
+ from .argument_parser import (
24
+ get_locustfiles_locally,
25
+ parse_locustfile_option,
26
+ parse_options,
27
+ )
24
28
  from .env import Environment
25
29
  from .html import get_html_report, process_html_filename
26
30
  from .input_events import input_listener
@@ -156,7 +160,12 @@ def merge_locustfiles_content(
156
160
  def main():
157
161
  # find specified locustfile(s) and make sure it exists, using a very simplified
158
162
  # command line parser that is only used to parse the -f option.
159
- locustfiles = parse_locustfile_option()
163
+ options, unknown = parse_locustfile_option()
164
+
165
+ if any([flag for flag in ["--login", "--logout", "--delete"] if flag in unknown]):
166
+ sys.exit(locust_cloud.main())
167
+
168
+ locustfiles = get_locustfiles_locally(options)
160
169
 
161
170
  # Importing Locustfile(s) - setting available UserClasses and ShapeClasses to choose from in UI
162
171
  (
@@ -166,14 +175,14 @@ def main():
166
175
  shape_class,
167
176
  ) = merge_locustfiles_content(locustfiles)
168
177
 
169
- stats.validate_stats_configuration()
170
-
171
178
  # parse all command line options
172
179
  options = parse_options()
173
180
 
174
181
  if getattr(options, "cloud", None):
175
182
  sys.exit(locust_cloud.main())
176
183
 
184
+ stats.validate_stats_configuration()
185
+
177
186
  if options.headful:
178
187
  options.headless = False
179
188
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: locust
3
- Version: 2.37.4.dev1
3
+ Version: 2.37.5.dev6
4
4
  Summary: Developer-friendly load testing framework
5
5
  Project-URL: homepage, https://locust.io/
6
6
  Project-URL: repository, https://github.com/locustio/locust
@@ -30,7 +30,7 @@ Requires-Dist: flask-login>=0.6.3
30
30
  Requires-Dist: flask>=2.0.0
31
31
  Requires-Dist: gevent<25.0.0,>=24.10.1
32
32
  Requires-Dist: geventhttpclient>=2.3.1
33
- Requires-Dist: locust-cloud>=1.21.5
33
+ Requires-Dist: locust-cloud>=1.21.7
34
34
  Requires-Dist: msgpack>=1.0.0
35
35
  Requires-Dist: psutil>=5.9.1
36
36
  Requires-Dist: pywin32; sys_platform == 'win32'
@@ -1,7 +1,7 @@
1
1
  locust/__init__.py,sha256=aWeuBPUxONjwNm1xp4v8L4BO14SuYLjscIiwJVX1Ui4,1746
2
2
  locust/__main__.py,sha256=vBQ82334kX06ImDbFlPFgiBRiLIinwNk3z8Khs6hd74,31
3
- locust/_version.py,sha256=47JK67mtjYv54zlxqNIFlVBMeNg9cXHDGgX6Hns-hVg,526
4
- locust/argument_parser.py,sha256=JDZftZ1sGknDXzYy-UrGndX7mGJUMhEjvruRjQjbNM4,33190
3
+ locust/_version.py,sha256=bA8RW_gEDOlHz5Zs0tyAlwpTNdv1erAUkKg84SaYLmM,526
4
+ locust/argument_parser.py,sha256=udbiBhZQfJVVIcLb4zHXRs7u4sQBl02_rogEUazfDik,32890
5
5
  locust/clients.py,sha256=o-277lWQdpmPnoRTdf3IQVNPQT8LMFDtPtuxbLHQIIs,19286
6
6
  locust/debug.py,sha256=7CCm8bIg44uGH2wqBlo1rXBzV2VzwPicLxLewz8r5CQ,5099
7
7
  locust/dispatch.py,sha256=prdwtb9EoN4A9klgiKgWuwQmvFB8hEuFHOK6ot62AJI,16202
@@ -11,7 +11,7 @@ locust/exception.py,sha256=jGgJ32ubuf4pWdlaVOkbh2Y0LlG0_DHi-lv3ib8ppOE,1791
11
11
  locust/html.py,sha256=VjoAEZEolJ8il4HLACBlVA81Qk36fBwlDj_7ojAEFss,4132
12
12
  locust/input_events.py,sha256=lqLDB2Ax-OQ7-vtYNkGjySjfaWVobBzqf0GxRwjcLcQ,3323
13
13
  locust/log.py,sha256=5E2ZUOa3V4sfCqa-470Gle1Ik9L5nxYitsjEB9tRwE0,3455
14
- locust/main.py,sha256=wY0FexiakPzK1oR4VbSzCQn3ARPsKZHWmhrObR9JWSI,28174
14
+ locust/main.py,sha256=6SVMbo2qcQGbWMz2xUixO7eegayQz2VCrQaMN4-kIh8,28399
15
15
  locust/py.typed,sha256=gkWLl8yD4mIZnNYYAIRM8g9VarLvWmTAFeUfEbxJLBw,65
16
16
  locust/runners.py,sha256=niYmGsfOpxMfVmTXGod4MYTefpaZ2wirFlhqxRw5mq4,70617
17
17
  locust/shape.py,sha256=t-lwBS8LOjWcKXNL7j2U3zroIXJ1b0fazUwpRYQOKXw,1973
@@ -51,8 +51,8 @@ locust/webui/dist/assets/graphs-light.png,sha256=7L6pOehXqCojQclzeP91l-LskFQAw_n
51
51
  locust/webui/dist/assets/index-Ufqx__MB.js,sha256=u9rbp7FXKwz3_7tA7fVBvRjWf_KUQFIL-yF3AN9YsD4,1722583
52
52
  locust/webui/dist/assets/testruns-dark.png,sha256=np6MvpgJ2gkKQ66SOmukLtjsMtHqTSr5dNfza-2XtCo,267621
53
53
  locust/webui/dist/assets/testruns-light.png,sha256=iLAxBZh3kRsfGkcB1-1KSAbFgGji43IqiUrYuJlUoPk,276839
54
- locust-2.37.4.dev1.dist-info/METADATA,sha256=s-VhaPiv5hv9kZWbywRXRVm8saHD73SMSra3go1pFs4,9403
55
- locust-2.37.4.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
- locust-2.37.4.dev1.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
57
- locust-2.37.4.dev1.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
58
- locust-2.37.4.dev1.dist-info/RECORD,,
54
+ locust-2.37.5.dev6.dist-info/METADATA,sha256=zKGkxzh6IYfJqBtTA7JT8ZGSXmpvaG--bRz1H0KRIwU,9403
55
+ locust-2.37.5.dev6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
56
+ locust-2.37.5.dev6.dist-info/entry_points.txt,sha256=RAdt8Ku-56m7bFjmdj-MBhbF6h4NX7tVODR9QNnOg0E,44
57
+ locust-2.37.5.dev6.dist-info/licenses/LICENSE,sha256=5hnz-Vpj0Z3kSCQl0LzV2hT1TLc4LHcbpBp3Cy-EuyM,1110
58
+ locust-2.37.5.dev6.dist-info/RECORD,,