def perspective_submitProblem(self, problem_no, problem_text, problem_lang): """Submit a problem""" if not self.contest_started: return None ts = self.contest.getContestAge() # If this submission was in the same second as before .. if ts == self._last_submitted_ts: ts = ts + 1 # add one second to make timestamps unique! self._last_submitted_ts = ts log.debug('SUBMIT: %d - %s' % (problem_no, problem_lang) ) # FIXME: renaming doesn't work for Java programs !! filename = 'p%d.%s' % (problem_no, \ self.profile.getLanguages()[problem_lang][2][0]) filepath = self.contest.copyFile( self, ts, filename, problem_text) workdir = os.path.split(filepath)[0] input_dict = { 'inpath': filepath, 'in': os.path.splitext(os.path.split(filepath)[1])[0] } self.contest.sm.submit( self, problem_no, problem_lang, ts, filepath) #reactor.callLater(0,self.profile.submitMeta, # self, input_dict, problem_no, problem_lang, # ts, workdir) return True
def remove(self, avatarId): "Called when an avatar logs out" log.debug('Avatar [%s] logs out' % avatarId) avatar = self._avatars[avatarId] avatar.logout() del self._avatars[avatarId] self.post(self.EVT_LOGOUT, avatar)
def followon1(result): "Add to database" sid = { 'users_id': team.id, 'problem': problem, 'language': language, 'ts': timestamp, 'result': result, } log.debug('DB_Add(sub): %s' % sid) df = self.contest.dbproxy.submissions_add(sid) df.addCallback(followon2, result, sid) return df
def _submit(self, s): log.debug(str(s)) try: judge = self._getTheMostIdleJudge() except NoJudgeError: log.warn('No judge logged in, buffering new runs!!') self._judge_queue[None].append(s) self._runsBuffered() else: result = judge.getSubmissionResult( s.team.userid, s.problem_no, s.problem_lang, s.filepath) queue = self._judge_queue[judge.userid] queue.append(s) result.addCallback(self._result, s) return result return None
def __init__(self, mind, contest, loginat, id, userid, emailid): """ @param mind: Client remote object @param contest: The contest object @param loginat: Timestamp when logged in @param id: The database row id of this user @param Userid: User id @param emailid: emailid of the user """ log.debug('AdminAvatar created - %s' % id) self.mind = None # see self.ready() self.id = id self.userid = userid self.emailid = emailid self.contest = contest self.dbproxy = contest.dbproxy self.loginat = loginat self.whoami = 'admin'
def __init__(self, mind, contest, loginat, id, userid, emailid, webclient=False): """ @param mind: Client remote object @param contest: The contest object @param loginat: Timestamp when logged in @param id: The database row id of this user @param Userid: User id @param emailid: emailid of the user """ log.debug('TeamAvatar created - %s' % id) self.mind = None # see self.ready() self.whoami = 'team' self.id = id self.loginat = loginat self.userid = userid self.emailid = emailid self.contest = contest self.webclient = webclient self.profile = contest.profile self.dbproxy = contest.dbproxy self.notify_defer = None # whether client is waiting self.contest_started = False self._last_submitted_ts = -1 # Timestamp of last submitted problem
def safe_spawn(pp, cmd_line, work_dir='.', res_limit_args=None): "Safe version of reactor.spawnProcess" executable, args = _safe_exec(cmd_line, work_dir, res_limit_args) log.debug('safe_spawn exe:[%s] args:[%s]' % (executable, args)) reactor.spawnProcess(pp, executable, args)
def system(callback, cb_arg, executable, args): "Asynchronous version of os.system using twisted's ProcessProtocol" pp = SimplePP(callback, cb_arg) log.debug('system exe:[%s] args:[%s]' % (executable, args)) reactor.spawnProcess(pp, executable, args)
def disconnect(self, avatarId): "Disconnect an avatar" log.debug('Avatar [%s] will be disconnected' % avatarId) transport = self._avatars[avatarId].mind.broker.transport transport.loseConnection()
def add(self, avatarId, avatar): "Called when an avatar logs in" log.debug('Avatar [%s] logs in' % avatarId) self._avatars[avatarId] = avatar self.post(self.EVT_LOGIN, avatar)