def load_work_list(): anno_dir = './nfs/lidar_data/labeled_data/' for path in os.listdir(anno_dir): subdir = os.path.join(anno_dir, path) if not os.path.exists(subdir) or path.find('lijie') > -1 or path.find('2018-01') > -1: continue bag_name = "bag-" + path.replace('.json', '') update_time = int(os.stat(subdir).st_mtime) create_time = int(os.stat(subdir).st_ctime) find_bag_name = ModelUtil.query_one(db_name, table_name, {"bag_name": bag_name}) if (find_bag_name is not None and find_bag_name['update_time'] != update_time) or find_bag_name is None: box_num = f_workload(subdir, ['0', '0', '0', '0', '0', '150']) box_num = str(int(round(box_num / 3.0, 2))) else: box_num = find_bag_name['box_num'] if find_bag_name is None: item = dict( bag_name=bag_name, box_num=box_num, update_time=update_time, create_time=create_time ) ModelUtil.add(db_name, table_name, item) ModelUtil.create_index(db_name, table_name, ['bag_name', 'box_num']) print('add %s' % item) elif find_bag_name is not None and find_bag_name['box_num'] != box_num: find_bag_name['box_num'] = box_num find_bag_name['update_time'] = update_time ModelUtil.update(db_name, table_name, find_bag_name) print('update: %s' % find_bag_name) update_request_work_time()
def view_user_create(): form = request.get_json() user_message = get_user_message({"username": form["username"]}) if user_message is None: form['mark_list'] = [] form['review_list'] = [] ModelUtil.add(db_name, table_name, form) return json_response_ok('success') else: return json_response_error(403, 'The username is exist.'), 200
def load_task_list(): anno_dir = './nfs/lidar_data/raw_data/' for path in os.listdir(anno_dir): item = { "marker": '', "reviewer": '', "bag_name": "bag-" + path.replace('.bag', ''), "status": 0 } if ModelUtil.exists(db_name, table_name, {"bag_name": "bag-" + path.replace('.bag', '')}): continue ModelUtil.add(db_name, table_name, item) ModelUtil.create_index(db_name, table_name, ['bag_name']) print('update done')
def update_request_work_time(): if not ModelUtil.exists(db_name, time_name, {}): ModelUtil.add(db_name, time_name, {'updated_time': timestamp()}) else: time = ModelUtil.query_one(db_name, time_name, {}, False) ModelUtil.update(db_name, time_name, time)
form = request.get_json() user_message = get_user_message({ "username": form["username"], "password": form["password"] }) if user_message is None: return json_response_error(402, 'The username or password is error.'), 200 else: register_login(user_message) user_message.pop("_id") return json_response_ok(user_message) @user.route('/logout/', methods=['POST']) @login_required def view_logout(): logout_user() return json_response_ok('success') if __name__ == "__main__": item = {} item["username"] = "******" item["password"] = "******" item["mark_list"] = [] item["review_list"] = [] item["role"] = 1 item["remark"] = 1 ModelUtil.add(db_name, table_name, item)