PyKubeGrader 0.2.16__tar.gz → 0.2.18__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. {pykubegrader-0.2.16/src/PyKubeGrader.egg-info → pykubegrader-0.2.18}/PKG-INFO +1 -1
  2. {pykubegrader-0.2.16 → pykubegrader-0.2.18/src/PyKubeGrader.egg-info}/PKG-INFO +1 -1
  3. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/PyKubeGrader.egg-info/SOURCES.txt +1 -0
  4. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/tokens/tokens.py +0 -6
  5. pykubegrader-0.2.18/src/pykubegrader/tokens/validate_token.py +69 -0
  6. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/.coveragerc +0 -0
  7. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/.github/workflows/main.yml +0 -0
  8. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/.gitignore +0 -0
  9. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/.readthedocs.yml +0 -0
  10. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/AUTHORS.rst +0 -0
  11. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/CHANGELOG.rst +0 -0
  12. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/CONTRIBUTING.rst +0 -0
  13. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/LICENSE.txt +0 -0
  14. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/README.rst +0 -0
  15. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/Makefile +0 -0
  16. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/_static/Drexel_blue_Logo_square_Dark.png +0 -0
  17. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/_static/Drexel_blue_Logo_square_Light.png +0 -0
  18. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/_static/custom.css +0 -0
  19. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/authors.rst +0 -0
  20. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/changelog.rst +0 -0
  21. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/conf.py +0 -0
  22. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/contributing.rst +0 -0
  23. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/index.rst +0 -0
  24. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/license.rst +0 -0
  25. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/readme.rst +0 -0
  26. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/docs/requirements.txt +0 -0
  27. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/examples/.responses.json +0 -0
  28. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/examples/true_false.ipynb +0 -0
  29. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/pyproject.toml +0 -0
  30. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/setup.cfg +0 -0
  31. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/setup.py +0 -0
  32. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/PyKubeGrader.egg-info/dependency_links.txt +0 -0
  33. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/PyKubeGrader.egg-info/entry_points.txt +0 -0
  34. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/PyKubeGrader.egg-info/not-zip-safe +0 -0
  35. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/PyKubeGrader.egg-info/requires.txt +0 -0
  36. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/PyKubeGrader.egg-info/top_level.txt +0 -0
  37. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/__init__.py +0 -0
  38. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/build/__init__.py +0 -0
  39. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/build/api_notebook_builder.py +0 -0
  40. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/build/build_folder.py +0 -0
  41. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/build/clean_folder.py +0 -0
  42. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/graders/__init__.py +0 -0
  43. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/graders/late_assignments.py +0 -0
  44. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/initialize.py +0 -0
  45. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/log_parser/__init__.py +0 -0
  46. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/log_parser/parse.ipynb +0 -0
  47. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/log_parser/parse.py +0 -0
  48. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/submit/submit_assignment.py +0 -0
  49. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/telemetry.py +0 -0
  50. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/utils.py +0 -0
  51. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/validate.py +0 -0
  52. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets/__init__.py +0 -0
  53. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets/multiple_choice.py +0 -0
  54. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets/reading_question.py +0 -0
  55. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets/select_many.py +0 -0
  56. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets/student_info.py +0 -0
  57. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets/style.py +0 -0
  58. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets/true_false.py +0 -0
  59. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets/types_question.py +0 -0
  60. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets_base/__init__.py +0 -0
  61. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets_base/multi_select.py +0 -0
  62. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets_base/reading.py +0 -0
  63. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/src/pykubegrader/widgets_base/select.py +0 -0
  64. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/tests/conftest.py +0 -0
  65. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/tests/import_test.py +0 -0
  66. {pykubegrader-0.2.16 → pykubegrader-0.2.18}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyKubeGrader
3
- Version: 0.2.16
3
+ Version: 0.2.18
4
4
  Summary: Add a short description here!
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: jagar2
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyKubeGrader
3
- Version: 0.2.16
3
+ Version: 0.2.18
4
4
  Summary: Add a short description here!
5
5
  Home-page: https://github.com/pyscaffold/pyscaffold/
6
6
  Author: jagar2
@@ -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,69 @@
1
+ import requests
2
+ import os
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 = None):
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
+
34
+ if token is not None:
35
+ os.environ["TOKEN"] = token
36
+
37
+ if token is None:
38
+ token = os.getenv("TOKEN", None)
39
+
40
+ if token is None:
41
+ raise TokenValidationError("No token provided")
42
+
43
+ try:
44
+ response = requests.get(endpoint, timeout=10)
45
+
46
+ if response.status_code == 200:
47
+ # If the response is 200, the token is valid
48
+ return # Pass silently
49
+ elif response.status_code == 404:
50
+ # If the response is 404, the token is invalid
51
+ raise TokenValidationError(response.json().get("detail", "Token not found"))
52
+ else:
53
+ # Handle unexpected status codes
54
+ raise TokenValidationError(
55
+ f"Unexpected response code: {response.status_code}"
56
+ )
57
+ except requests.RequestException as e:
58
+ # Raise an exception for connection errors or timeout
59
+ raise TokenValidationError(f"Request failed: {e}")
60
+
61
+
62
+ # Example usage
63
+ if __name__ == "__main__":
64
+ token = "test"
65
+ try:
66
+ validate_token(token)
67
+ print("Token is valid.")
68
+ except TokenValidationError as e:
69
+ 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