@@ -34,7 +34,7 @@ def __init__(self, program_name, lang, output, inp = None):
3434 self .inp = inp
3535 self .language_id = languages [lang ]
3636
37- def readCode (self ):
37+ def __readCode (self ):
3838 """
3939 Read Source Code & return as string
4040 """
@@ -43,39 +43,38 @@ def readCode(self):
4343 return data
4444
4545
46- def readExpectedOutput (self ):
46+ def __readExpectedOutput (self ):
4747 with open (self .output , 'r' ) as out :
4848 data = out .read ()
4949 return data
5050
5151
52- def readStandardInput (self ):
52+ def __readStandardInput (self ):
5353 with open (self .inp , 'r' ) as out :
5454 data = out .read ()
5555 return data
5656
5757
58- def readStatus (self , token ):
58+ def __readStatus (self , token ):
5959 """
6060 Check Submission status
6161 """
6262 while True :
6363 req = requests .get (API_URL + token ['token' ])
64- response = req .json ()
65- status = response ['status' ]['description' ]
64+ self .__response = req .json ()
65+ self .__memory = self .__response ["memory" ]
66+ self .__time = self .__response ["time" ]
67+ status = self .__response ['status' ]['description' ]
6668 if status != "Processing" and status != "In Queue" :
6769 break
68- print (status )
6970
7071 if status == "Accepted" :
71- #print(f'Output : \n{response["stdout"]}')
72- print (f'Time : { response ["time" ]} ' )
73- print ("Compile Success ✅" )
72+ self .__stdout = self .__response ["stdout" ]
7473 return status
7574 else :
76- return response ['status' ]['description' ]
75+ return self . __response ['status' ]['description' ]
7776
78- def submit (self ):
77+ def __submit (self ):
7978 if self .inp != None :
8079 api_params ['stdin' ] = self .inp
8180
@@ -88,16 +87,34 @@ def submit(self):
8887 return token
8988
9089
90+ def getStandardOutput (self ):
91+ return self .__stdout
92+
93+
94+ def getMemory (self ):
95+ return self .__memory
96+
97+
98+ def getError (self ):
99+ if self .__response ['stderr' ] != '' :
100+ return self .__response ['stderr' ]
101+ return None
102+
103+
104+ def getTime (self ):
105+ return self .__time
106+
107+
91108 def run (self ):
92- self .program_name = self .readCode ()
93- self .output = self .readExpectedOutput ()
109+ self .program_name = self .__readCode ()
110+ self .output = self .__readExpectedOutput ()
94111
95112 if self .inp != None :
96- self .inp = self .readStandardInput ()
97- token = self .submit ()
98- status = self .readStatus (token )
113+ self .inp = self .__readStandardInput ()
114+ token = self .__submit ()
115+ status = self .__readStatus (token )
99116 else :
100- token = self .submit ()
101- status = self .readStatus (token )
117+ token = self .__submit ()
118+ status = self .__readStatus (token )
102119 return status
103120
0 commit comments