예제 #1
0
 def update(self,ids,lat,lng,height,name):
     json_msg = jfac.createUpdate(ids,lat,lng,height,name)   
     resp = requests.get("%s/update/?jsonMsg=%s&sid=90908978"%(self.service_url,json_msg))
     json_obj = json.loads('%s'%resp.content)
     if json_obj['Error']:
         return False
     else:
         return True
예제 #2
0
 def delete(self,ids):
     json_msg = jfac.createDelete(ids)  
     resp = requests.get("%s/delete/?jsonMsg=%s&sid=90908978"%(self.service_url,json_msg))
     json_obj = json.loads('%s'%resp.content)
     if json_obj['Error']:
         return False
     else:
         return True
예제 #3
0
 def search_for_users(self,lat,lng,lat_rng,lng_rng):
     print "search for users in %s:%s , %s:%s"%(lat,lng,lat_rng,lng_rng)
     msg = jfac.createSearchUsers(lat,lng,lat_rng,lng_rng)
     resp = self._sendHttpPost(msg,"request")
     resp_obj = json.loads(resp)
     ret_obj=[]
     for obj in resp_obj:
         ret_obj.append(obj['pk'])
     return ret_obj
예제 #4
0
 def get(self,ids):
     json_msg = jfac.createGet(ids)   
     resp = requests.get("%s/get/?jsonMsg=%s&sid=90908978"%(self.service_url,json_msg))
     print "Get::%s"%resp.content
     json_obj = json.loads('%s'%resp.content)
     if json_obj['Error']:
         return None
     else:
         return json_obj['info']
예제 #5
0
 def search(self,lat=None,lng=None,height=None,lat_rng=None,lng_rng=None,height_rng=None,name=None):
     json_msg = jfac.createSearch(lat,lng,height,lat_rng,lng_rng,height_rng,name)  
     resp = requests.get("%s/search/?jsonMsg=%s&sid=90908978"%(self.service_url,json_msg))
     json_obj = json.loads('%s'%resp.content)
     if 'Error' in json_obj:
         return None
     else:
         return json_obj
     return str(json_obj)
예제 #6
0
 def update_user(self,lat,lng,id):
     print "update user location at %s %s id is %s"%(lat,lng,id)
     msg = jfac.createUpdateUser(lat,lng,id)
     return self._sendHttpPost(msg,"request")
예제 #7
0
 def rem_user(self,id):
     print "remove user from db %s"%id
     msg = jfac.createRemUser(id)
     return self._sendHttpPost(msg,"request")
예제 #8
0
 def add_user(self,lat,lng):
     print "add new user %s %s"%(lat,lng)
     msg = jfac.createAddUser(lat,lng)
     resp = self._sendHttpPost(msg,"request")
     resp_obj = json.loads(resp)
     return "%s"%resp_obj[0]['pk']
예제 #9
0
 def __init__(self):
     print "Login to Locality Service Starting the User Session using %s %s"%(un,pw)
     msg = jfac.createLogin(un,pw)
     resp = self._sendHttpPost(msg,"system_login")
     print "%s"%resp
예제 #10
0
 def insert(self,lat,lng,height,name):
     json_msg = jfac.createInsert(lat,lng,height,name) 
     resp = requests.get("%s/insert/?jsonMsg=%s&sid=90908978"%(self.service_url,json_msg))
     json_obj = json.loads('%s'%resp.content)
     return json_obj['id']