Exemple #1
0
def updateWithPhone(messageid,phone,lat,lon):
    es_client = ElasticSearch("http://ec2-54-219-169-37.us-west-1.compute.amazonaws.com:9200")
    producer1 = mark4deletionByLatLon(es_client, 'messages', 'myMessages', lat, lon)    
    markid = producer1.marking()
    #if the rider/driver is still available, remove the corresponding initiating driver/rider and confirm.
    if markid != 1:
        producer2 = updateByMessageid(es_client, 'messages', 'myMessages', messageid)    
        success = producer2.updating()
        if success == 1:
            message = "You have been selected by other driver/rider."
        else:
            es_client.delete('messages', 'myMessages', markid)
            message = "Both driver and rider have been confirmed! Please contact " + phone
            
    else:       
        message = "The driver/rider isn't available anymore. Please select again!"
        
    return render_template("confirm.html", message = message)
Exemple #2
0
 def simulating(self):
     producer = matchRides(self.client,self.index,self.type,self.deplocation,self.arrlocation,self.drflag)
     result = producer.matching()
     if (result != 1):    #found matching drivers/riders
         (deplats,deplons,arrlats,arrlons,dist,messageid,phone) = result
         
         #randomly pick up a user
         pickup=random.choice(range(len(deplats)))
         print "picking up driver/rider %d" % pickup
         
         requestingProducer = mark4deletionByLatLon(self.client, self.index, self.type, self.deplocation[0], self.deplocation[1])    
         markid = requestingProducer.marking()
         #if the requesting rider/driver is still available, check whether the requested driver/rider is available.
         if markid != 1:
             requestedProducer = updateByMessageid(self.client, self.index, self.type, messageid[pickup])    
             success = requestedProducer.updating()
             if success == 1:
                 print "The driver/rider isn't available anymore. Please select again!"
             else:
                 self.client.delete(self.index, self.type, markid)
                 print "Both driver and rider have been confirmed!"
                 
         else:
             print "You have been selected by other driver/rider."