def post(self, id=None): self.logger.info("%s: post" % __name__) if id is None: return self.make_http_response( False, 'need a location id, single data should be bind to a location item' ) try: location_obj = LocationList.get_by_id(id) if location_obj is None: raise ObjectNotExist('Location id is wrong') if OBJECT_DATA_N not in self.req_dict: return self.make_http_response(False, 'request data is invalid') req_obj = InverseTest.to_obj(self.req_dict[OBJECT_DATA_N], location_obj) if InverseTest.is_exist(req_obj): return self.make_http_response( False, 'InverseTest is exist, can not add any more!') # commit the data , so id will refresh from database InverseTest.add(req_obj, True) location_obj.set_inv_id(req_obj.id) LocationList.add(location_obj) except ObjectNotExist as e: self.logger.error(e.what()) return self.make_http_response(False, e.what()) return self.make_http_response(True, 'Add InverseTest Success!')
def delete(self, id=None): self.logger.info('%s: delete' % __name__) if id is not None: return self.make_http_response(False, 'need a id arg') try: LocationList.delete(id) except DBException as e: return self.make_http_response(False, 'delete id is not exist') return self.make_http_response(True, 'delete success')
def delete(self, id=None): self.logger.info('%s: delete' % __name__) if id is None: return self.make_http_response(False, 'need a id arg') ste_obj = SingleCalibration.get_by_id(id) if ste_obj is None: return self.make_http_response(False, 'delete stereo data not exist') obj_list = LocationList.query().filter(LocationList.single_ca_id == id).all() # remove all Location item's single id link for obj in obj_list: obj.stereo_ca_id = None LocationList.add(obj) return self.delete_base(SingleCalibration, id)
def delete(self, id=None): self.logger.info('%s: delete' % __name__) if id is None: return self.make_http_response(False, 'this request method need a id arg') ste_obj = DH_Optimised.get_by_id(id) if ste_obj is None: return self.make_http_response(False, 'delete stereo data not exist') obj_list = LocationList.query().filter(LocationList.stereo_ca_id == id).all() # remove all Location item's stereo id link for obj in obj_list: obj.stereo_ca_id = None LocationList.add(obj) return self.delete_base(DH_Optimised, id)
def delete(self, id=None): self.logger.info('%s: delete' % __name__) if id is None: return self.make_http_response( False, 'this request method need a id arg') ste_obj = GenerateData.get_by_id(id) if ste_obj is None: return self.make_http_response(False, 'delete stereo data not exist') obj_list = LocationList.query().filter(LocationList.g_id == id).all() # todo: LocationList.g_id can not be None # remove all Location item with generate data id link for obj in obj_list: LocationList.delete(obj) return self.delete_base(GenerateData, id)
def put(self, id=None): self.logger.info("%s: put" % __name__) try: if id is not None: return self.make_http_response(False, 'need not a id arg') if OBJECT_DATA_N not in self.req_dict: return self.make_http_response(False, 'request data is invalid') req_loc = LocationList.update_obj(self.req_dict[OBJECT_DATA_N]) if req_loc is None: return self.make_http_response( False, 'LocationList update data invalid') print(req_loc.use_type) LocationList.add(req_loc, True) except ObjectNotExist as e: return self.make_http_response(False, e.what()) return self.make_http_response(True, 'update success')
def post(self, id=None): self.logger.info("%s: post" % __name__) try: if id is not None: return self.make_http_response(False, 'need not a id arg') if OBJECT_DATA_N not in self.req_dict: return self.make_http_response(False, 'request data is invalid') req_loc = LocationList.to_obj(self.req_dict[OBJECT_DATA_N]) if LocationList.is_exist(req_loc): return self.make_http_response( False, 'LocationList is exist, can not add any more!') LocationList.add(req_loc) except ObjectNotExist as e: return self.make_http_response(False, e.what()) return self.make_http_response(True, 'Add LocationList Success!')
def put(self, id=None): self.logger.info("%s: put" % __name__) self.logger.info("id: %d" % id) try: if id is None: return self.make_http_response(False, 'need a location id') location_obj = LocationList.get_by_id(id) print(LocationList.to_dict(location_obj)) if OBJECT_DATA_N not in self.req_dict: return self.make_http_response(False, 'request data is invalid') req_ste = InverseTest.update_obj(self.req_dict[OBJECT_DATA_N], location_obj) if req_ste is None: return self.make_http_response(False, 'camera update data invalid') InverseTest.add(req_ste) except ObjectNotExist as e: self.logger.error(e.what()) return self.make_http_response(False, e.what()) return self.make_http_response(True, 'update success')
def post(self, id=None): self.logger.info("%s: post" % __name__) try: if id is not None: return self.make_http_response(False, 'this request method need not id arg') location_obj = LocationList.get_by_id(id) if location_obj is None: return self.make_http_response(False, 'Location obj is not exist which id is %s' % str(id)) if OBJECT_DATA_N not in self.req_dict: return self.make_http_response(False, 'request data is invalid') req_obj = DH_Optimised.to_obj(self.req_dict[OBJECT_DATA_N], location_obj) if DH_Optimised.is_exist(req_obj): return self.make_http_response(False, 'DH_Optimised is exist, can not add any more!') # commit the data , so id will refresh from database DH_Optimised.add(req_obj, True) location_obj.set_dh_id(req_obj.id) LocationList.add(location_obj) except ObjectNotExist as e: self.logger.error(e.what()) return self.make_http_response(False, e.what()) return self.make_http_response(True, 'Add DH_Optimised Success!')
def get(self, location_id, table_name, filename): self.logger.info('%s: get %s' % (__name__, filename)) loc_obj = LocationList.get_by_id(location_id) if loc_obj is None: self.make_http_response(False, 'file not exist') file_path = loc_obj.get_upload_path() + '/' + str(table_name) + '/' if not os.path.exists(file_path + filename): # raise ObjectNotExist('file not exist') return self.make_http_response(False, 'file not exist') response = send_from_directory(file_path, filename, as_attachment=True) response.headers['Content-Disposition'] += "; %s*=utf-8''{}" % filename return response
def post(self, location_id, table_name): self.logger.info("%s : post" % __name__) if table_name not in self.table_name_list: return self.make_http_response(False, 'table name must be one of %s' % str(self.table_name_list)) if self.req_dict is not None and 'is_cover' in self.req_dict and self.req_dict['is_cover'] is True: is_cover = True else: is_cover = False loc_obj = LocationList.get_by_id(location_id) if loc_obj is None: return self.make_http_response(False, 'Location obj is not exist which id is %s' % str(location_id)) ret_obj = self._save_files(reqparse.request.files.to_dict(), loc_obj, table_name, is_cover) return self.make_http_response(True, 'upload result', msg_obj=ret_obj)
def put(self, id=None): self.logger.info("%s: put" % __name__) self.logger.info("id: %d" % id) try: if id is not None: return self.make_http_response(False, 'this request method need not id arg') location_obj = LocationList.get_by_id(id) if OBJECT_DATA_N not in self.req_dict: return self.make_http_response(False, 'request data is invalid') req_ste = DH_Optimised.update_obj(self.req_dict[OBJECT_DATA_N], location_obj) if req_ste is None: return self.make_http_response(False, 'camera update data invalid') DH_Optimised.add(req_ste) except ObjectNotExist as e: self.logger.error(e.what()) return self.make_http_response(False, e.what()) return self.make_http_response(True, 'update success')
def put(self, id=None): self.logger.info("%s: put" % __name__) try: if id is not None: return self.make_http_response(False, 'need not a id arg') loc_obj = LocationList.get_by_id(id) if loc_obj is None: return self.make_http_response(False, 'Location obj is not exist which id is %s' % str(id)) if OBJECT_DATA_N not in self.req_dict: return self.make_http_response(False, 'request data is invalid') req_ste = SingleCalibration.update_obj(self.req_dict[OBJECT_DATA_N], loc_obj) if req_ste is None: return self.make_http_response(False, 'camera update data invalid') SingleCalibration.add(req_ste) except ObjectNotExist as e: self.logger.error(e.what()) return self.make_http_response(False, e.what()) return self.make_http_response(True, 'update success')
sql_object.engine.execute('USE %s' % DB_NAME) # select db to use sql_object.create_all(app=test_app) try: test_user = User("test1", "test1", "TestHello5") test_user1 = User("test2", "test2", "TestHello6") test_camera = Camera("test3", "test3", "TestHello7") test_robot = Robot("test4", 4, "RR") test_gen = GenerateData("test4", 1) Camera.add(test_camera) Robot.add(test_robot) User.add(test_user1) User.add(test_user, True) GenerateData.add(test_gen, True) test_single = SingleCalibration("test3") test_stereo = StereoCalibration("test3", "test3") test_dh = DH_Optimised(DH_Model.Faset) test_inv = InverseTest() test_loc = LocationList(1) SingleCalibration.add(test_single) StereoCalibration.add(test_stereo) DH_Optimised.add(test_dh) InverseTest.add(test_inv) LocationList.add(test_loc, True) except ObjectNotExist as e: print(e.what()) # # User.add(1) print("test end")