locust-cloud 1.0.7__py3-none-any.whl → 1.0.8__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_cloud/__init__.py CHANGED
@@ -1,10 +1,11 @@
1
- from locust_cloud.auth import register_auth
2
- from locust_cloud.timescale.exporter import Timescale
3
-
4
1
  import os
5
2
 
3
+ os.environ["LOCUST_SKIP_MONKEY_PATCH"] = "1"
4
+
6
5
  from locust import events
7
6
  from locust.argument_parser import LocustArgumentParser
7
+ from locust_cloud.auth import register_auth
8
+ from locust_cloud.timescale.exporter import Timescale
8
9
 
9
10
  PG_USER = os.environ.get("PG_USER")
10
11
  PG_HOST = os.environ.get("PG_HOST")
@@ -12,16 +13,21 @@ PG_PASSWORD = os.environ.get("PG_PASSWORD")
12
13
  PG_DATABASE = os.environ.get("PG_DATABASE")
13
14
  PG_PORT = os.environ.get("PG_PORT", 5432)
14
15
 
15
- os.environ["LOCUST_BUILD_PATH"] = os.path.join(os.path.dirname(__file__), "webui/dist")
16
-
17
16
 
18
17
  @events.init_command_line_parser.add_listener
19
18
  def add_arguments(parser: LocustArgumentParser):
19
+ if not PG_HOST:
20
+ parser.add_argument_group(
21
+ "locust-cloud",
22
+ "locust-cloud disabled, because PG_HOST was not set - this is normal for local runs",
23
+ )
24
+ return
25
+
26
+ os.environ["LOCUST_BUILD_PATH"] = os.path.join(os.path.dirname(__file__), "webui/dist")
20
27
  locust_cloud = parser.add_argument_group(
21
28
  "locust-cloud",
22
- "Arguments for use with Locust cloud!",
29
+ "Arguments for use with Locust cloud",
23
30
  )
24
-
25
31
  locust_cloud.add_argument(
26
32
  "--exporter",
27
33
  default=True,
@@ -40,6 +46,9 @@ def add_arguments(parser: LocustArgumentParser):
40
46
 
41
47
  @events.init.add_listener
42
48
  def on_locust_init(environment, **args):
49
+ if not PG_HOST:
50
+ return
51
+
43
52
  if environment.parsed_options.exporter:
44
53
  Timescale(
45
54
  environment,
locust_cloud/auth.py CHANGED
@@ -1,5 +1,5 @@
1
- import datetime
2
1
  import os
2
+ from datetime import UTC, datetime, timedelta
3
3
 
4
4
  import requests
5
5
  from flask import redirect, request, url_for
@@ -21,9 +21,9 @@ def set_credentials(credentials, response):
21
21
  user_sub_id = credentials["user_sub_id"]
22
22
  refresh_token = credentials["refresh_token"]
23
23
 
24
- response.set_cookie("cognito_token", id_token, expires=datetime.datetime.utcnow() + datetime.timedelta(days=1))
25
- response.set_cookie("user_token", refresh_token, expires=datetime.datetime.utcnow() + datetime.timedelta(days=365))
26
- response.set_cookie("user_sub_id", user_sub_id, expires=datetime.datetime.utcnow() + datetime.timedelta(days=365))
24
+ response.set_cookie("cognito_token", id_token, expires=datetime.now(tz=UTC) + timedelta(days=1))
25
+ response.set_cookie("user_token", refresh_token, expires=datetime.now(tz=UTC) + timedelta(days=365))
26
+ response.set_cookie("user_sub_id", user_sub_id, expires=datetime.now(tz=UTC) + timedelta(days=365))
27
27
 
28
28
  return response
29
29
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: locust-cloud
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: Locust Cloud
5
5
  Requires-Python: >=3.11
6
6
  Requires-Dist: blessed==1.20.0
@@ -1,5 +1,5 @@
1
- locust_cloud/__init__.py,sha256=ZpA79bNf7scS9qM45j7YNHRYQqAd9MzrQKreYU0OmzE,1480
2
- locust_cloud/auth.py,sha256=5cIhUgaENeYSe_GxNp3v7rLhB4_Pj9URFrLYYsRG-n8,3042
1
+ locust_cloud/__init__.py,sha256=A5I1PXZzB6FF2YgHq_hw4dLXUUt0FSkhAZG3lho1zng,1769
2
+ locust_cloud/auth.py,sha256=kSSEbOcfZHNWmn802pAS01ooiNm1IIa29Ui_-rku4lM,3027
3
3
  locust_cloud/cloud.py,sha256=_TnyFaQG4rhd4msIs2I6QhAWOUDeRmcZXGzH4cEx2aI,12724
4
4
  locust_cloud/timescale/exporter.py,sha256=j1K-czMUdOLFt5Sop0PTF6TL52vYdngEEI5OEM3Xl60,11128
5
5
  locust_cloud/webui/.eslintrc,sha256=huuuTZNwbBGkhfelEOMhLQ-tgC9OYnnX0DRYgBn83Ig,1146
@@ -13,7 +13,7 @@ locust_cloud/webui/vite.config.ts,sha256=cqxPMkbwEA3H9mGGbuPulQUhIHCosUqm_1usxzs
13
13
  locust_cloud/webui/yarn.lock,sha256=yysZ-wROYB43fp1k_YC4zhLBjJKWr3_C6vKWM4rx0b4,216553
14
14
  locust_cloud/webui/dist/index.html,sha256=WiAeD-vj6jDZ1Q3-odnAPyM9hmc5pT6gvcq9YI65U9o,664
15
15
  locust_cloud/webui/dist/assets/index-CCS97q-k.js,sha256=3-KSz2kFRL7YG3rMB1dUCffEByaK7Zny5cuzxSgn5x8,2795908
16
- locust_cloud-1.0.7.dist-info/METADATA,sha256=zo39FGyY4bMlOwy7NW2aka7J-oo3H-tRhqDdqKxZ7aM,2162
17
- locust_cloud-1.0.7.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
18
- locust_cloud-1.0.7.dist-info/entry_points.txt,sha256=PGyAb4e3aTsGS3N3VGShDl6VzJaXy7QwsEgsLOC7V00,57
19
- locust_cloud-1.0.7.dist-info/RECORD,,
16
+ locust_cloud-1.0.8.dist-info/METADATA,sha256=Z2BBT52kMftSU9AVSA-mOfdgz_pWQ8IMtj-fOoZ-l64,2162
17
+ locust_cloud-1.0.8.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
18
+ locust_cloud-1.0.8.dist-info/entry_points.txt,sha256=PGyAb4e3aTsGS3N3VGShDl6VzJaXy7QwsEgsLOC7V00,57
19
+ locust_cloud-1.0.8.dist-info/RECORD,,