def delete_ros_file(filename): log.info("delete pcd file: {}".format(filename)) try: bag_dir = current_app.config.get('BAG_DIR') file = os.path.join(app.root_path, bag_dir) + filename fileutil.delete(file) return ResponseModel.ok('done') except Exception, ex: traceback.print_exc() log.error(ex.message) return ResponseModel.error(ex.message)
def force_type(cls, ResponseModel, environ=None): if isinstance(Response, (list, dict, object)): response = jsonify(ResponseModel.serialze()) return super(Response, cls).force_type(response, environ)
def get_record_files(): bag_dir = current_app.config.get('BAG_DIR') return ResponseModel.ok(fileutil.get_ros_bag_files(bag_dir))
def ros_record_close(): while not rospy.is_shutdown(): RosCommon().close() return ResponseModel.msg('ros record closed!')
def ros_record(): try: RosCommon().record() except Exception, e: traceback.print_exc() return ResponseModel.error(e.message)
def ros_launch_start(): try: RosCommon().launch_start('test.launch') except Exception, e: traceback.print_exc() return ResponseModel.error(e.message)
log = logging.getLogger(__name__) def validate_json(json): if not json or not hasattr(json, 'items'): raise NoJsonException() @api.route('/launch/start', methods=['GET', 'POST']) def ros_launch_start(): try: RosCommon().launch_start('test.launch') except Exception, e: traceback.print_exc() return ResponseModel.error(e.message) return ResponseModel.ok('launch start') @api.route('/record', methods=['GET']) def ros_record(): try: RosCommon().record() except Exception, e: traceback.print_exc() return ResponseModel.error(e.message) return ResponseModel.ok('ros record done!') @api.route('/close', methods=['GET', 'POST']) def ros_record_close(): while not rospy.is_shutdown():