fix: 修复数据目录迁移导致的目录错误问题

This commit is contained in:
maxmon 2023-04-12 23:42:59 +08:00
parent e40e2678ad
commit f628c10db0
5 changed files with 9 additions and 10 deletions

View File

@ -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)

View File

@ -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', '')

View File

@ -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))

View File

@ -13,7 +13,7 @@ FILE_NAME = 'fileName'
PROJECTS = 'app/projects'
# 项目路径
PROJECT_PATH = PROJECTS + '/{}/data/'
PROJECT_PATH = PROJECTS + '/{}/'
PROJECT_CONFIG_PATH = PROJECTS + '/' + "{}" + '/config.json'
#下载标注结果所在的位置

View File

@ -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):