コード例 #1
0
    def tick(self):
        global master
        global current
        global dataLock
        global submitted
        global ticking
        global clients
        global pointSystem
        global lock
        self.logref().write(self.tag+"Tick active.  Acquiring lock!")
        dataLock.acquire()
        ticking=True
        self.logref().write(self.tag+"Updating @current.brak")
        current.setNext(master)
        writer = open("brackets\\@current.brak", mode='w')
        writer.write(current.dump())
        writer.close()
        self.logref().write(self.tag+"@current.brak updated.  Rescoring users")
        for user in list(submitted):
            reader = open("brackets\\"+user+".brak")
            brak = bracket.bracketBuilder(reader.read())
            reader.close()
            clients[user].lastKnownScore=brak.score(current, pointSystem)
            clients[user].save()
            self.logref().write(self.tag+"finished scoring "+str(user))
##        self.logref().write(self.tag+"Updating time lock")
##        lock = (date.today()>=date(2014,4,8))
##        self.logref().write(self.tag+"Time Lock status: "+ str(lock))
        dataLock.release()
        ticking=False
        self.sock.sockSend("DONE")
        self.logref().write(self.tag+"Tick complete.  lock released")
コード例 #2
0
 def viewBracket(self, user):
     global submitted
     global current
     global dataLock
     global pointSystem
     global clients
     self.logref().write(self.tag+"viewing bracket")
     if(user.rstrip()=="@MasterBracket"):
         self.logref().write(self.tag+"Sending current master bracket")
         self.sock.sockSend("0")
         self.sock.sockSend("0")
         self.sock.sockSend(current.correctness(current))
         return
     elif(user not in submitted):
         self.logref().write(self.tag+"BAD")
         self.stop=True
         self.sock.sockDisconnect()
         return
     dataLock.acquire()
     reader = open("brackets\\"+user+".brak")
     intake=reader.read()
     reader.close()
     dataLock.release()
     outBracket= bracket.bracketBuilder(intake)
     self.logref().write(self.tag+"Updating score of requested bracket")
     outScore=outBracket.score(current, pointSystem)
     self.sock.sockSend(str(outScore))
     self.sock.sockSend(str(outBracket.ppr(current, pointSystem)))
     output=outBracket.correctness(current)
     dataLock.acquire()
     clients[user].lastKnownScore=outScore
     clients[user].save()
     dataLock.release()
     self.sock.sockSend(output)
コード例 #3
0
 def getCorrect(self):
     global submitted
     global current
     if(self.username in submitted):
         reader=open("brackets\\"+self.username+".brak")
         brak=bracket.bracketBuilder(reader.read())
         reader.close()
         return brak.numCorrect(current)
     return 0
コード例 #4
0
 def createBracket(self, session):
     global sessions
     global submitted
     global lock
     global current
     global dataLock
     global pointSystem
     self.logref().write(self.tag+"Creating new bracket")
     if((session not in sessions) or lock):
         self.logref().write(self.tag+"DUN")
         self.stop=True
         self.sock.sockDisconnect()
         return
     user=sessions[session]
     self.logref().write(self.tag+"REC")
     self.sock.sockSend("GO")
     intake = self.sock.sockRec()
     self.logref().write(self.tag+"Aquiring Lock")
     dataLock.acquire()
     writer = open("brackets\\"+user.username+".brak", mode='w')
     writer.write(intake)
     writer.close()
     submitted= submitted|set([user.username])
     writer=open("clients\\@submitted.brak",mode='w')
     for thing in list(submitted):
         writer.write(thing.rstrip()+'\n')
     writer.close()
     self.logref().write(self.tag+"Bracket made")
     reader=open("brackets\\"+user.username+".brak")
     temp = bracket.bracketBuilder(reader.read())
     reader.close()
     writer = open("brackets\\"+user.username+".brak", mode='w')
     writer.write(temp.dump())
     writer.close()
     sessions[session].lastKnownScore=temp.score(current, pointSystem)
     dataLock.release()
     self.logref().write(self.tag+"Bracket reformatted")
     self.sock.sockSend("GO")
コード例 #5
0
        
        
serverLog = Logger()
reader=open("clients\\@clientlist.brak")
clientNames=reader.readlines()
reader.close()
for name in clientNames:
    clients[name.rstrip()]=Client("RELOAD::"+name.rstrip(), "1948535")
reader=open("clients\\@submitted.brak")
submittedNames=reader.readlines()
reader.close()
submitted=set([name.rstrip() for name in submittedNames])
reader=open("brackets\\@master.brak")
masterSource=reader.read()
reader.close()
master=bracket.bracketBuilder(masterSource)
reader=open("brackets\\@current.brak")
currentSource=reader.read()
reader.close()
current=bracket.bracketBuilder(currentSource)
reader=open("brackets\\@key.brak")
key="".join(reader.readlines())
reader.close()
reader=open("brackets\\@source.brak")
source="".join(reader.readlines())
reader.close()

clients["@admin"]=Client("@admin", newEncrypt("BRACKETS_ADMIN!", passwordKey), "*****@*****.**")

    
primary=newInterface()