Example #1
0
 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!')
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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')
Example #5
0
    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!')
Example #6
0
 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!')
Example #7
0
    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")