From f628c10db06b446ceb138c623781c37326c76e7d Mon Sep 17 00:00:00 2001 From: maxmon <541182180@qq.com> Date: Wed, 12 Apr 2023 23:42:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E8=BF=81=E7=A7=BB=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- be/app/api/v1/anno.py | 2 +- be/app/api/v1/files.py | 5 +++-- be/app/api/v1/project.py | 2 +- be/app/config/setting.py | 2 +- be/app/libs/tools.py | 8 +++----- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/be/app/api/v1/anno.py b/be/app/api/v1/anno.py index a54d191..b82f03f 100644 --- a/be/app/api/v1/anno.py +++ b/be/app/api/v1/anno.py @@ -37,7 +37,7 @@ def query_anno(): project_name = request.args.get("projectName").strip() file_name = request.args.get("fileName").strip() - file_path = PROJECT_PATH.format(project_name) + '/' + file_name + file_path = PROJECT_PATH.format(project_name) + '/data/' + file_name file_content = read_file(file_path) anno_output_path = ANNO_OUTPUT_PATH.format(project_name, file_name) diff --git a/be/app/api/v1/files.py b/be/app/api/v1/files.py index ed3fb1c..3bb6d84 100644 --- a/be/app/api/v1/files.py +++ b/be/app/api/v1/files.py @@ -26,7 +26,9 @@ def query_file(): project_path = PROJECT_PATH.format(project_name) if not os.path.exists(project_path): os.makedirs(project_path) - file_names = os.listdir(project_path) + os.makedirs(project_path + '/data') + os.makedirs(project_path + '/anno') + file_names = os.listdir(project_path + '/data') if 'config.json' in file_names: file_names.remove('config.json') if 'anno.json' in file_names: @@ -85,7 +87,6 @@ def get_lables(): return json.dumps(download_json, default=lambda o: o.__dict__) @api.route('/get_anno_json', methods=['GET']) -@api.route('/get_json', methods=['GET']) def get_anno_json(): project_name = request.args.get("projectName") anno_output_dir = ANNO_OUTPUT_PATH.format(project_name, '').replace('.json', '') diff --git a/be/app/api/v1/project.py b/be/app/api/v1/project.py index f8f8094..f3974de 100644 --- a/be/app/api/v1/project.py +++ b/be/app/api/v1/project.py @@ -39,7 +39,7 @@ def get_zipped_data(): upload_file = request.files['file'] file_path = os.path.join(PROJECT_PATH.format(project_name), upload_file.filename) - target_path = PROJECT_PATH.format(project_name) + target_path = PROJECT_PATH.format(project_name) + '/data' upload_file.save(file_path) file_type = file_path.split('.')[-1] # print("zipped data received: .{} form".format(file_type)) diff --git a/be/app/config/setting.py b/be/app/config/setting.py index 813d94c..4c3694d 100644 --- a/be/app/config/setting.py +++ b/be/app/config/setting.py @@ -13,7 +13,7 @@ FILE_NAME = 'fileName' PROJECTS = 'app/projects' # 项目路径 -PROJECT_PATH = PROJECTS + '/{}/data/' +PROJECT_PATH = PROJECTS + '/{}/' PROJECT_CONFIG_PATH = PROJECTS + '/' + "{}" + '/config.json' #下载标注结果所在的位置 diff --git a/be/app/libs/tools.py b/be/app/libs/tools.py index 4ba8a9d..142a068 100644 --- a/be/app/libs/tools.py +++ b/be/app/libs/tools.py @@ -20,7 +20,7 @@ def make_dir(path): folder = os.path.exists(path) if not folder: - os.mkdir(path) + os.makedirs(path) # 将json数据写入.json文件 def write_json(json_file_path, data): @@ -58,10 +58,8 @@ def read_txt_file(file_path): def get_project_file(project_path): - file_name = os.listdir(project_path) - file_name.remove('anno.json') - file_name.remove('config.json') - return file_name + file_names = os.listdir(project_path + '/data') + return file_names def unzip_file(zip_src, dst_dir):