Update helper.py
Browse files
helper.py
CHANGED
@@ -1,6 +1,49 @@
|
|
1 |
import jwt
|
2 |
import uuid
|
3 |
from datetime import datetime, timedelta
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def create_jwt(github_user_login: str, user_id: int) -> str:
|
6 |
"""
|
@@ -38,4 +81,4 @@ def create_jwt(github_user_login: str, user_id: int) -> str:
|
|
38 |
"plan": "Free"
|
39 |
}
|
40 |
|
41 |
-
return jwt.encode(payload, 'llm-secret', algorithm='HS256')
|
|
|
1 |
import jwt
|
2 |
import uuid
|
3 |
from datetime import datetime, timedelta
|
4 |
+
import random
|
5 |
+
import string
|
6 |
+
|
7 |
+
|
8 |
+
def get_github_username_zed_userid_list():
|
9 |
+
"""
|
10 |
+
Read GitHub usernames and Zed user IDs from gh_username_zed_userid.txt file.
|
11 |
+
|
12 |
+
Returns:
|
13 |
+
list: A list of tuples, each containing a GitHub username (str) and a Zed user ID (int).
|
14 |
+
"""
|
15 |
+
result = []
|
16 |
+
try:
|
17 |
+
with open('gh_username_zed_userid.txt', 'r') as file:
|
18 |
+
for line in file:
|
19 |
+
username, user_id = line.strip().split(',')
|
20 |
+
result.append((username, user_id))
|
21 |
+
except FileNotFoundError:
|
22 |
+
print("Warning: gh_username_zed_userid.txt file not found. Using default values.")
|
23 |
+
result = [("aaa", "123123")]
|
24 |
+
except ValueError:
|
25 |
+
print("Warning: Invalid format in gh_username_zed_userid.txt. Using default values.")
|
26 |
+
result = [("aaa", "123123")]
|
27 |
+
|
28 |
+
return result
|
29 |
+
|
30 |
+
# def generate_random_tuple():
|
31 |
+
# """
|
32 |
+
# Generate a random tuple containing a string and an integer.
|
33 |
+
|
34 |
+
# Returns:
|
35 |
+
# tuple: A tuple containing:
|
36 |
+
# - str: A random string of length 6-12 consisting of ASCII letters and digits.
|
37 |
+
# - int: A random 6-digit integer between 100000 and 999999.
|
38 |
+
# """
|
39 |
+
# # Generate a random string of length 6-12
|
40 |
+
# random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=random.randint(6, 12)))
|
41 |
+
|
42 |
+
# # Generate a random 6-digit integer
|
43 |
+
# random_int = random.randint(100000, 999999)
|
44 |
+
|
45 |
+
# return (random_string, random_int)
|
46 |
+
|
47 |
|
48 |
def create_jwt(github_user_login: str, user_id: int) -> str:
|
49 |
"""
|
|
|
81 |
"plan": "Free"
|
82 |
}
|
83 |
|
84 |
+
return jwt.encode(payload, 'llm-secret', algorithm='HS256')
|