PyKubeGrader 0.2.16__tar.gz → 0.2.17__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pykubegrader-0.2.16/src/PyKubeGrader.egg-info → pykubegrader-0.2.17}/PKG-INFO +1 -1
- {pykubegrader-0.2.16 → pykubegrader-0.2.17/src/PyKubeGrader.egg-info}/PKG-INFO +1 -1
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/PyKubeGrader.egg-info/SOURCES.txt +1 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/tokens/tokens.py +0 -6
- pykubegrader-0.2.17/src/pykubegrader/tokens/validate_token.py +59 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/.coveragerc +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/.github/workflows/main.yml +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/.gitignore +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/.readthedocs.yml +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/AUTHORS.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/CHANGELOG.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/CONTRIBUTING.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/LICENSE.txt +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/README.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/Makefile +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/_static/Drexel_blue_Logo_square_Dark.png +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/_static/Drexel_blue_Logo_square_Light.png +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/_static/custom.css +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/authors.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/changelog.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/conf.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/contributing.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/index.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/license.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/readme.rst +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/docs/requirements.txt +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/examples/.responses.json +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/examples/true_false.ipynb +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/pyproject.toml +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/setup.cfg +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/setup.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/PyKubeGrader.egg-info/dependency_links.txt +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/PyKubeGrader.egg-info/entry_points.txt +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/PyKubeGrader.egg-info/not-zip-safe +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/PyKubeGrader.egg-info/requires.txt +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/PyKubeGrader.egg-info/top_level.txt +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/__init__.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/build/__init__.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/build/api_notebook_builder.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/build/build_folder.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/build/clean_folder.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/graders/__init__.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/graders/late_assignments.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/initialize.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/log_parser/__init__.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/log_parser/parse.ipynb +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/log_parser/parse.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/submit/submit_assignment.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/telemetry.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/utils.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/validate.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets/__init__.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets/multiple_choice.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets/reading_question.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets/select_many.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets/student_info.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets/style.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets/true_false.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets/types_question.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets_base/__init__.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets_base/multi_select.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets_base/reading.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/src/pykubegrader/widgets_base/select.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/tests/conftest.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/tests/import_test.py +0 -0
- {pykubegrader-0.2.16 → pykubegrader-0.2.17}/tox.ini +0 -0
@@ -48,6 +48,7 @@ src/pykubegrader/log_parser/parse.ipynb
|
|
48
48
|
src/pykubegrader/log_parser/parse.py
|
49
49
|
src/pykubegrader/submit/submit_assignment.py
|
50
50
|
src/pykubegrader/tokens/tokens.py
|
51
|
+
src/pykubegrader/tokens/validate_token.py
|
51
52
|
src/pykubegrader/widgets/__init__.py
|
52
53
|
src/pykubegrader/widgets/multiple_choice.py
|
53
54
|
src/pykubegrader/widgets/reading_question.py
|
@@ -3,12 +3,6 @@ import os
|
|
3
3
|
import json
|
4
4
|
|
5
5
|
|
6
|
-
# try:
|
7
|
-
# from pykubegrader.build.passwords import password, user
|
8
|
-
# except: # noqa: E722
|
9
|
-
# print("Passwords not found, cannot access database")
|
10
|
-
|
11
|
-
|
12
6
|
def build_token_payload(token: str, duration: int) -> dict:
|
13
7
|
|
14
8
|
if os.getenv("JUPYTERHUB_USER", None) is None:
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import requests
|
2
|
+
|
3
|
+
|
4
|
+
class TokenValidationError(Exception):
|
5
|
+
"""
|
6
|
+
Custom exception raised when the token validation fails.
|
7
|
+
"""
|
8
|
+
|
9
|
+
def __init__(self, message=None):
|
10
|
+
"""
|
11
|
+
Initialize the exception with an optional message.
|
12
|
+
|
13
|
+
Args:
|
14
|
+
message (str, optional): The error message to display. Defaults to None.
|
15
|
+
"""
|
16
|
+
super().__init__(message)
|
17
|
+
|
18
|
+
|
19
|
+
def validate_token(token):
|
20
|
+
"""
|
21
|
+
Validate a token by making a GET request to the validation endpoint.
|
22
|
+
|
23
|
+
Args:
|
24
|
+
token (str): The token to validate.
|
25
|
+
|
26
|
+
Raises:
|
27
|
+
TokenValidationError: If the token is invalid or if there is an error in the validation process.
|
28
|
+
|
29
|
+
Returns:
|
30
|
+
None: If the token is valid, the function will pass silently.
|
31
|
+
"""
|
32
|
+
endpoint = f"https://engr-131-api.eastus.cloudapp.azure.com/validate-token/{token}"
|
33
|
+
try:
|
34
|
+
response = requests.get(endpoint, timeout=10)
|
35
|
+
|
36
|
+
if response.status_code == 200:
|
37
|
+
# If the response is 200, the token is valid
|
38
|
+
return # Pass silently
|
39
|
+
elif response.status_code == 404:
|
40
|
+
# If the response is 404, the token is invalid
|
41
|
+
raise TokenValidationError(response.json().get("detail", "Token not found"))
|
42
|
+
else:
|
43
|
+
# Handle unexpected status codes
|
44
|
+
raise TokenValidationError(
|
45
|
+
f"Unexpected response code: {response.status_code}"
|
46
|
+
)
|
47
|
+
except requests.RequestException as e:
|
48
|
+
# Raise an exception for connection errors or timeout
|
49
|
+
raise TokenValidationError(f"Request failed: {e}")
|
50
|
+
|
51
|
+
|
52
|
+
# Example usage
|
53
|
+
if __name__ == "__main__":
|
54
|
+
token = "test"
|
55
|
+
try:
|
56
|
+
validate_token(token)
|
57
|
+
print("Token is valid.")
|
58
|
+
except TokenValidationError as e:
|
59
|
+
print(f"Token validation failed: {e}")
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|