def replace(self, request, eventType, rome_score, gaul_score, auth_id):
        print 'Current Berk Sync Time'
        print time.time() + BackEnd.getTimeDiff()
        if auth_id == 'Cacofonix':
            data = BackEnd.getDataJSON()
            for e in data['Team']:
                if e == 'Rome':
                    data['Team'][e][eventType]['Score'] = rome_score
                if e == 'Gual':
                    data['Team'][e][eventType]['Score'] = gaul_score
            BackEnd.updateDataJSON(data)

            data = BackEnd.getDataJSON()
            dat1 = data['Team']['Gual'][eventType]['Score']
            dat2 = data['Team']['Rome'][eventType]['Score']
            #             if eventType == "Stone Curling":
            #                 a = data['Clients']
            #                 flag = set()     # creating a set to ignore duplicate port so that notification is passed over to correct clients
            #                 for i in a:
            #                     flag.add(str(i['port']))
            #                     for i in flag:
            #                         print i
            #                     url = "http://127.0.0.1:"+i+"/pushUpdate/Stone Curling/"+rome_score+"/"+gaul_score
            #                     requests.put(url)
            return json.dumps({'Gual': dat1, 'Rome': dat2})

        else:
            return "Failure to add Authorization failed"
Example #2
0
    def read(self, request, eventType):
        print 'Current Berk Sync Time'
        print time.time() + BackEnd.getTimeDiff()
        data = BackEnd.getDataJSON()
        dat1 = data['Team']['Gual'][eventType]['Score']
        dat2 = data['Team']['Rome'][eventType]['Score']
        ret = json.dumps({'Gual': dat1, 'Rome': dat2})

        return ret
    def replace(self, request, clientID, eventType, port):
        data = BackEnd.getDataJSON()
        print 'Current Berk Sync Time'
        print time.time() + BackEnd.getTimeDiff()
        data['Clients'].append({'clientID': clientID, 'port': port})

        if eventType == "Stone Curling":
            BackEnd.updateDataJSON(data)
        else:
            print "NOT ADDED"
        return "Success"
 def read(self, request, teamName):
     print 'Current Berk Sync Time'
     print time.time() + BackEnd.getTimeDiff()
     data=BackEnd.getDataJSON();
     for e in data['Team']:
         if e == teamName:
             dat = data['Team'][e]
     dat.pop('Stone Curling',0)
     dat.pop('Stone Throwing',0)
     dat.pop('Stone Skating',0)
     return json.dumps({teamName:dat})
 def index(self, request):
     print 'Current Berk Sync Time'
     print time.time() + BackEnd.getTimeDiff()
     data=BackEnd.getDataJSON();
     dat1 = data['Team']['Gual']
     dat2 = data['Team']['Rome']
     dat1.pop('Stone Skating',0)
     dat1.pop('Stone Curling',0)
     dat1.pop('Stone Throwing',0)
     dat2.pop('Stone Skating',0)
     dat2.pop('Stone Curling',0)
     dat2.pop('Stone Throwing',0)
     ret={'Gual':dat1,'Rome':dat2}
     return json.dumps(ret)
    def replace(self, request, teamName, medalType, auth_id):
        print 'Current Berk Sync Time'
        print time.time() + BackEnd.getTimeDiff()
        if auth_id == 'Cacofonix':
            data = BackEnd.getDataJSON()
            for e in data['Team']:
                if e == teamName:
                    if medalType == 'Gold':
                        data['Team'][teamName]['Gold'] += 1
                    if medalType == 'Silver':
                        data['Team'][teamName]['Silver'] += 1
                    if medalType == 'Bronze':
                        data['Team'][teamName]['Bronze'] += 1

            BackEnd.updateDataJSON(data)
            return json.dumps({teamName: data['Team'][teamName]})
        else:
            return 'Not Authorized'