Пример #1
0
    def run(self):
        print "starts file update for all users"
        #sleep(1)
        encoder = json.JSONEncoder()
        bd = DB_Accesser()

        users = bd.Get_AllUsersInSession({"sessionID": self.sessionid})
        files = bd.Get_AllFilesFromSession({"sessionID": self.sessionid})

        data = {"sessionID": self.sessionid, "fileList": files}
        datastr = encoder.encode(data)
        cmdstr = unichr(UPDATE_FILES)

        for usr in users:

            print "update files for user " + usr["email"]

            skt = socketlist[usr["email"]][0]
            mtx = socketlist[usr["email"]][2]

            sendstr = "SHARINF" + cmdstr + datastr + "\endF"

            mtx.acquire()
            n_send = skt.sendall(sendstr)
            #while(n_send is not None):
            #    n_send = skt.sendall(sendstr)
            mtx.release()

        print "files update done!"
        return
Пример #2
0
    def fileListHandle(self, data):

        db = DB_Accesser()

        files = db.Get_AllFilesFromSession(data)

        datajson = {"fileList": files}

        if files is not None:
            self.returnSuccess(SESSION_FILELIST, datajson)
        else:
            self.returnInsucess(SESSION_FILELIST)