333
This commit is contained in:
1 parent
a7d509b666
commit
7e87d37f53
2 files changed
+28
-7
No files matched your search
@@ -289,7 +289,7 @@ def download_datas_by_json(pid_file, workdir, oss_config):
|
||||
# 批量下载
|
||||
for model_info in list_model_info:
|
||||
print(f"开始下载PID: {model_info}")
|
||||
download_data_by_json(model_info, args.workdir, oss_client,)
|
||||
download_data_by_json(model_info, workdir, oss_client,)
|
||||
|
||||
return data, need_transform
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ def requestApiToUpdateSliceStatus(versionId,downloadCounts):
|
||||
def step1(versionId):
|
||||
jsonFilePath = f'batchPrint/{versionId}/{versionId}.json'
|
||||
#判断oss 上是否存在
|
||||
jpgFilePath = f'batchPrint/{versionId}/{versionId}.jpg'
|
||||
|
||||
if not ossClient().object_exists(jsonFilePath):
|
||||
return False
|
||||
@@ -87,14 +88,34 @@ def step1(versionId):
|
||||
os.makedirs(dirNow)
|
||||
localFilePath = os.path.join(dirNow, f'{versionId}.json')
|
||||
ossClient().get_object_to_file(jsonFilePath, localFilePath)
|
||||
return True
|
||||
#判断 json 文件里的 selected_machine 值是否是大机型
|
||||
with open(localFilePath, 'r', encoding='utf-8') as f:
|
||||
jsonData = json.load(f)
|
||||
selectedMachine = jsonData.get('selected_machine')
|
||||
|
||||
diirNewName = ""
|
||||
if selectedMachine == '大机型':
|
||||
#修改 dirNow 目录里的 versionId 命名为 versionId_big
|
||||
dirNewName = os.path.join(dirNow, versionId + '_big')
|
||||
os.rename(os.path.join(dirNow, versionId), dirNewName)
|
||||
else:
|
||||
#修改 dirNow 目录里的 versionId 命名为 versionId_small
|
||||
dirNewName = versionId + '_small'
|
||||
os.rename(os.path.join(dirNow, versionId), dirNewName)
|
||||
|
||||
|
||||
if ossClient().object_exists(jpgFilePath):
|
||||
localJpgFilePath = os.path.join(dirNewName,"json", f'{versionId}.jpg')
|
||||
ossClient().get_object_to_file(jpgFilePath, localJpgFilePath)
|
||||
|
||||
return dirNewName
|
||||
|
||||
#根据下载下来的JSON文件传递,调用其它参数,进行处理
|
||||
def step2(jsonFilePath, versionId):
|
||||
def step2(jsonFilePath,folder, versionId):
|
||||
print(f'jsonFilePath={jsonFilePath}, versionId={versionId} {currentDir}/download_print_out.py')
|
||||
# 直接调用函数,而不是通过os.system执行python命令
|
||||
# 这样可以避免在打包成exe后找不到python命令的问题
|
||||
workdir = os.path.join(currentDir, 'batchPrint', versionId, 'data')
|
||||
workdir = os.path.join(folder, 'data')
|
||||
download_transform_save_by_json(jsonFilePath, workdir, '')
|
||||
|
||||
|
||||
@@ -144,12 +165,12 @@ def main(work_dir=None):
|
||||
shutil.rmtree(objFilePath)
|
||||
|
||||
res = step1(versionId)
|
||||
if not res:
|
||||
if res == False:
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} JSON文件下载数据失败,等待10秒')
|
||||
time.sleep(10)
|
||||
continue
|
||||
jsonFilePath = os.path.join(currentDir, 'batchPrint', versionId, 'json', f'{versionId}.json')
|
||||
step2(jsonFilePath, versionId)
|
||||
jsonFilePath = os.path.join(res, 'json', f'{versionId}.json')
|
||||
step2(res,res, versionId)
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 数据处理完成,等待10秒')
|
||||
|
||||
#判断下载的obj文件数量和json里的是否一致,排除arrange文件夹
|
||||
|
||||
Reference in new issue
Block a user