Exemplo n.º 1
0
 def start(self):
     self.Judging.start()
     self.Download.start()
     connect = Connect()
     while True:
         message = connect.get_message()
         try:
             if message[0] == '0':
                 JudgeServer.judge_task.put(message[1:])
             elif message[0] == '1':
                 ProblemServer.problem_task.put(message[1:])
             elif message[0] == '2':
                 try:
                     p = Problem(message[1], message[2], 0)
                 except IndexError:
                     connect.receive_message("")
                 else:
                     title = p.get_title()
                     connect.receive_message("%s" % title)
             elif message[0] == '3':
                 connect.receive_message("0")
             elif message[0] == '4':
                 pass
             elif message[0] == '5':
                 oj = message[1]
                 username = message[2]
                 password = message[3]
                 cid = int(message[4])
                 c = Contest(oj, username, password, cid, -1)
                 connect.receive_message("%d" % c.get_problem_number())
             elif message[0] == '6':
                 oj = message[1]
                 username = message[2]
                 password = message[3]
                 cid = int(message[4])
                 contest_id = int(message[5])
                 c = Contest(oj, username, password, cid, contest_id)
                 c.start()
             else:
                 raise IndexError
         except IndexError:
             logging.error("Error message!!! message: " + ' '.join(message))
         else:
             connect.receive_message()
             connect.close_connect()
Exemplo n.º 2
0
 def run(self):
     if ProblemServer.semaphore.acquire():
         p = Problem(self.oj, self.problem_id, self.pid)
         p.run()
         ProblemServer.semaphore.release()