locust-cloud 1.20.5__py3-none-any.whl → 1.20.6__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.
@@ -8,6 +8,8 @@ from locust_cloud.common import VALID_REGIONS, __version__, get_api_url, read_cl
8
8
 
9
9
  logger = logging.getLogger(__name__)
10
10
 
11
+ unauthorized_message = "You need to log in again. Please run:\n locust --cloud --login"
12
+
11
13
 
12
14
  class ApiSession(requests.Session):
13
15
  def __init__(self, non_interactive: bool) -> None:
@@ -39,28 +41,28 @@ class ApiSession(requests.Session):
39
41
  print(f"Authentication failed: {response.text}")
40
42
  sys.exit(1)
41
43
 
42
- self.__refresh_token = response.json()["refresh_token"]
43
44
  id_token = response.json()["cognito_client_id_token"]
44
45
  user_sub_id = response.json()["user_sub_id"]
46
+ refresh_token = response.json()["refresh_token"]
45
47
  id_token_expires = response.json()["id_token_expires"]
46
48
  else:
47
49
  config = read_cloud_config()
48
50
 
49
51
  if config.refresh_token_expires < time.time() + 24 * 60 * 60:
50
- message = "You need to authenticate before proceeding. Please run:\n locust-cloud --login"
51
- print(message)
52
+ print(unauthorized_message)
52
53
  sys.exit(1)
53
54
 
54
55
  assert config.region
55
56
  self.__configure_for_region(config.region)
56
- self.__refresh_token = config.refresh_token
57
57
  id_token = config.id_token
58
58
  user_sub_id = config.user_sub_id
59
+ refresh_token = config.refresh_token
59
60
  id_token_expires = config.id_token_expires
60
61
 
61
62
  assert id_token
62
63
 
63
64
  self.__user_sub_id = user_sub_id
65
+ self.__refresh_token = refresh_token
64
66
  self.__id_token_expires = id_token_expires - 60 # Refresh 1 minute before expiry
65
67
  self.headers["Authorization"] = f"Bearer {id_token}"
66
68
  self.headers["X-Client-Version"] = __version__
@@ -75,6 +77,9 @@ class ApiSession(requests.Session):
75
77
  def __ensure_valid_authorization_header(self) -> None:
76
78
  if self.__id_token_expires > time.time():
77
79
  return
80
+ if not self.__user_sub_id and self.__refresh_token:
81
+ print(unauthorized_message)
82
+ sys.exit(1)
78
83
 
79
84
  response = requests.post(
80
85
  self.__login_url,
@@ -89,7 +94,7 @@ class ApiSession(requests.Session):
89
94
  # TODO: Technically the /login endpoint can return a challenge for you
90
95
  # to change your password.
91
96
  # Now that we have a web based login flow we should force them to
92
- # do a locust-cloud --login if we get that.
97
+ # do a locust --cloud --login if we get that.
93
98
 
94
99
  id_token = response.json()["cognito_client_id_token"]
95
100
  id_token_expires = response.json()["id_token_expires"]
locust_cloud/args.py CHANGED
@@ -186,7 +186,7 @@ combined_cloud_parser = configargparse.ArgumentParser(
186
186
  ),
187
187
  description="""Launches a distributed Locust runs on locust.cloud infrastructure.
188
188
 
189
- Example: locust-cloud -f my_locustfile.py --users 1000 ...""",
189
+ Example: locust --cloud -f my_locustfile.py --users 1000 ...""",
190
190
  epilog="""Any parameters not listed here are forwarded to locust master unmodified, so go ahead and use things like --users, --host, --run-time, ...
191
191
  Locust config can also be set using config file (~/.locust.conf, locust.conf, pyproject.toml, ~/.cloud.conf or cloud.conf).
192
192
  Parameters specified on command line override env vars, which in turn override config files.""",
@@ -1,6 +1,6 @@
1
- ============
2
- Locust Cloud
3
- ============
1
+ =========================
2
+ Running with Locust Cloud
3
+ =========================
4
4
 
5
5
  .. include:: 1-first-run.rst
6
6
  .. include:: 2-examples.rst
locust_cloud/web_login.py CHANGED
@@ -62,7 +62,7 @@ If the browser does not open or you wish to use a different device to authorize
62
62
  print(f"\nFailed to authorize CLI: {data['reason']}")
63
63
  sys.exit(1)
64
64
  elif data["state"] == "authorized":
65
- print("\nAuthorization succeded. Now you can re-run locust-cloud without the --login flag.")
65
+ print("\nAuthorization succeded. Now you can re-run locust --cloud without the --login flag.")
66
66
  break
67
67
  else:
68
68
  print("\nGot unexpected response when authorizing CLI")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: locust-cloud
3
- Version: 1.20.5
3
+ Version: 1.20.6
4
4
  Summary: Locust Cloud
5
5
  Project-URL: homepage, https://locust.cloud
6
6
  Project-URL: repository, https://github.com/locustcloud/locust-cloud
@@ -1,18 +1,18 @@
1
1
  locust_cloud/__init__.py,sha256=6z2hE5rUP9WJyYgr-7XC2GhIV-05m8XxjOsnb8ae1WY,56
2
- locust_cloud/apisession.py,sha256=gWqNADGL3H745fefm_tE1O1516OBfOhqZRlc-BgIudM,4224
3
- locust_cloud/args.py,sha256=warMJQvUg_liowJWHS0XF400rQQ0PUigPSutfwG9BLY,7661
2
+ locust_cloud/apisession.py,sha256=fz3mJsHbS-LdlVcuaJurf4_nq_Oa_XdBTZ7sVpux_mA,4376
3
+ locust_cloud/args.py,sha256=KD2svA77-Dz98J7p-WiSr9wIiA7GJ2wCglIcFOccncs,7663
4
4
  locust_cloud/cloud.py,sha256=LFO_Ykst0bOBYPqfxS6ll7abAvCCqyUpD3ql4nem9ys,6264
5
5
  locust_cloud/common.py,sha256=GVKkWcbbqd9n8oU-fHZRVZw3jGtuIVGSCLD2ZizeEo0,1160
6
6
  locust_cloud/input_events.py,sha256=MyxccgboHByICuK6VpQCCJhZQqTZAacNmkSpw-gxBEw,3420
7
- locust_cloud/web_login.py,sha256=Byu62DKyf8NSbPdP9I2Q3lJh_lZgxjn0OZcRgnMIlXg,2555
7
+ locust_cloud/web_login.py,sha256=UTwuRJBCkdsGkzHmzwW_s03GKABR22gScq-nBMmqcag,2557
8
8
  locust_cloud/websocket.py,sha256=9Q7nTFuAwVhgW74DlJNcHTZXOQ1drsXi8hX9ciZhWlQ,8998
9
9
  locust_cloud/docs/.gitignore,sha256=ghNPcjYkjQXNS_eVmu2hQFhq6FIUliAD1O2CJhulS2o,10
10
10
  locust_cloud/docs/1-first-run.rst,sha256=Z34qKIxIniwCELeUmEQbNLsN7HWM5fq-a3Wc4fuapG0,1091
11
11
  locust_cloud/docs/2-examples.rst,sha256=bYElk5GbDWo8ZtBwbdK1lfnySF7EZ3ycST1BYEyFid4,9537
12
- locust_cloud/docs/locust-cloud.rst,sha256=NMfWGZdT0YPa0gPPuOcKplzBcqiEK7buPzXHOlzY5T0,98
12
+ locust_cloud/docs/locust-cloud.rst,sha256=q0WSBOJI0LR3zxuaE9Lor0_bzv4AOKr3aCz9VC6sIzs,137
13
13
  locust_cloud/docs/images/locust-cloud-screenshot.png,sha256=ag0IxBi-40VexC84MApol1GCgRCL2h-l8NQDTMaeTyE,477350
14
- locust_cloud-1.20.5.dist-info/METADATA,sha256=YzP49vyactP3LQMLmSY8SiH9AbX_KKTa-ZsKhQ7PpkA,644
15
- locust_cloud-1.20.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- locust_cloud-1.20.5.dist-info/entry_points.txt,sha256=PGyAb4e3aTsGS3N3VGShDl6VzJaXy7QwsEgsLOC7V00,57
17
- locust_cloud-1.20.5.dist-info/licenses/LICENSE,sha256=Ow6fY6ta4KIjdlWalmxGvRP8yLmetvkbkl-SdHMjPIs,1093
18
- locust_cloud-1.20.5.dist-info/RECORD,,
14
+ locust_cloud-1.20.6.dist-info/METADATA,sha256=5rHgcrYsaLPBPOcEwrZku_Jbqs_7qy-iJBndvjmQM-I,644
15
+ locust_cloud-1.20.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ locust_cloud-1.20.6.dist-info/entry_points.txt,sha256=PGyAb4e3aTsGS3N3VGShDl6VzJaXy7QwsEgsLOC7V00,57
17
+ locust_cloud-1.20.6.dist-info/licenses/LICENSE,sha256=Ow6fY6ta4KIjdlWalmxGvRP8yLmetvkbkl-SdHMjPIs,1093
18
+ locust_cloud-1.20.6.dist-info/RECORD,,