def get_building_description(self, path): """ format /api/user/building/entry/description/1 where 1 is the building id """ if len(path) < self.PATH_START_IDX + 2: raise BadRequest("To retrieve building services. You must supply a building id. Ex. /api/user/building/entry/description/1 for retrieving it for building where id = 1") buildingID = self._get_buildingID(path) b = Manager.lookup(buildingID) # Hint pyDev about our type assert isinstance(b, BifBase) floor = dict() floor['numFloors'] = b.getNumFloors() rooms = dict() for r in b.getRooms(): print type(r) assert isinstance(r, Room) rooms[str(r.getLogicalID())] = r.getFullRepresentation() root = dict() root['rooms'] = rooms return root
def obj_get_list(self, request=None, **kwargs): filters = {} print Manager.get_available_buildings() b = Manager.lookup(1) if hasattr(request, 'GET'): # Grab a mutable copy. filters = request.GET.copy() print request print filters # Update with the provided kwargs. filters.update(kwargs) t = inspect.getmembers(BifBase, predicate=inspect.ismethod) return t
def set_service(self, path): ''' format /api/user/building/entry/set/buildingid/service_id/value where service_id is the service id and value is the value that you wish to set for the actuator/service.''' if len(path) < self.PATH_START_IDX + 4: raise BadRequest("To set building services. You must supply a service id and its new value. Ex. /api/user/building/entry/set/buildingid/serviceid/0.") buildingID = self._get_buildingID(path) serviceID = self._get_serviceID(path) value = self._get_value(path) # Instantiate building if its not already done so Manager.lookup(buildingID) Manager.set_building_service(buildingID, serviceID, value) r = dict() r['returnvalue'] = True return r
def set_service(self, request, **kwargs): """ format /api/user/building/entry/set/buildingid/service_id/value where service_id is the service id and value is the value that you wish to set for the actuator/service.""" path = request.path.split("/") print path if len(path) < self.PATH_START_IDX + 4: raise BadRequest( "To set building services. You must supply a service id and its new value. Ex. /api/user/building/entry/set/buildingid/serviceid/0." ) buildingID = self._get_buildingID(path) serviceID = self._get_serviceID(path) value = self._get_value(path) # Instantiate building if its not already done so Manager.lookup(buildingID) Manager.set_building_service(buildingID, serviceID, value) r = dict() r["returnvalue"] = True return self.create_response(request, r)