1
- from typing import Iterable , Optional , Union
1
+ from typing import Iterable , Union
2
2
3
3
import requests
4
4
5
- from .retry import RegularPeriodRetry , RetryMechanism
6
-
7
5
from .submission import Submission
8
6
9
7
10
8
class Client :
9
+ API_KEY_ENV = "JUDGE0_API_KEY"
10
+
11
11
def __init__ (self , endpoint , auth_headers ) -> None :
12
12
self .endpoint = endpoint
13
13
self .auth_headers = auth_headers
14
+
14
15
try :
15
16
self .languages = {lang ["id" ]: lang for lang in self .get_languages ()}
16
- except Exception :
17
- raise RuntimeError ("Client authentication failed." )
17
+ except Exception as e :
18
+ raise RuntimeError ("Client authentication failed." ) from e
18
19
19
20
def get_about (self ) -> dict :
20
21
r = requests .get (
@@ -172,6 +173,8 @@ def get_submissions(
172
173
173
174
174
175
class ATD (Client ):
176
+ API_KEY_ENV = "JUDGE0_ATD_API_KEY"
177
+
175
178
def __init__ (self , endpoint , host_header_value , api_key ):
176
179
self .api_key = api_key
177
180
super ().__init__ (
@@ -323,6 +326,8 @@ def get_submissions(
323
326
324
327
325
328
class Rapid (Client ):
329
+ API_KEY_ENV = "JUDGE0_RAPID_API_KEY"
330
+
326
331
def __init__ (self , endpoint , host_header_value , api_key ):
327
332
self .api_key = api_key
328
333
super ().__init__ (
@@ -359,6 +364,8 @@ def __init__(self, api_key):
359
364
360
365
361
366
class Sulu (Client ):
367
+ API_KEY_ENV = "JUDGE0_SULU_API_KEY"
368
+
362
369
def __init__ (self , endpoint , api_key ):
363
370
self .api_key = api_key
364
371
super ().__init__ (endpoint , {"Authorization" : f"Bearer { api_key } " })
@@ -376,3 +383,10 @@ class SuluJudge0ExtraCE(Sulu):
376
383
377
384
def __init__ (self , api_key ):
378
385
super ().__init__ (self .DEFAULT_ENDPOINT , api_key = api_key )
386
+
387
+
388
+ DEFAULT_CE_CLIENT_CLASS = SuluJudge0CE
389
+ DEFAULT_EXTRA_CE_CLASS = SuluJudge0ExtraCE
390
+
391
+ CE = [RapidJudge0CE , SuluJudge0CE , ATDJudge0CE ]
392
+ EXTRA_CE = [RapidJudge0ExtraCE , SuluJudge0ExtraCE , ATDJudge0ExtraCE ]
0 commit comments