|
|
|
@ -78,6 +78,7 @@ def requestApiToUpdateSliceStatus(versionId,downloadCounts): |
|
|
|
def step1(versionId): |
|
|
|
def step1(versionId): |
|
|
|
jsonFilePath = f'batchPrint/{versionId}/{versionId}.json' |
|
|
|
jsonFilePath = f'batchPrint/{versionId}/{versionId}.json' |
|
|
|
#判断oss 上是否存在 |
|
|
|
#判断oss 上是否存在 |
|
|
|
|
|
|
|
jpgFilePath = f'batchPrint/{versionId}/{versionId}.jpg' |
|
|
|
|
|
|
|
|
|
|
|
if not ossClient().object_exists(jsonFilePath): |
|
|
|
if not ossClient().object_exists(jsonFilePath): |
|
|
|
return False |
|
|
|
return False |
|
|
|
@ -87,14 +88,34 @@ def step1(versionId): |
|
|
|
os.makedirs(dirNow) |
|
|
|
os.makedirs(dirNow) |
|
|
|
localFilePath = os.path.join(dirNow, f'{versionId}.json') |
|
|
|
localFilePath = os.path.join(dirNow, f'{versionId}.json') |
|
|
|
ossClient().get_object_to_file(jsonFilePath, localFilePath) |
|
|
|
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文件传递,调用其它参数,进行处理 |
|
|
|
#根据下载下来的JSON文件传递,调用其它参数,进行处理 |
|
|
|
def step2(jsonFilePath, versionId): |
|
|
|
def step2(jsonFilePath,folder, versionId): |
|
|
|
print(f'jsonFilePath={jsonFilePath}, versionId={versionId} {currentDir}/download_print_out.py') |
|
|
|
print(f'jsonFilePath={jsonFilePath}, versionId={versionId} {currentDir}/download_print_out.py') |
|
|
|
# 直接调用函数,而不是通过os.system执行python命令 |
|
|
|
# 直接调用函数,而不是通过os.system执行python命令 |
|
|
|
# 这样可以避免在打包成exe后找不到python命令的问题 |
|
|
|
# 这样可以避免在打包成exe后找不到python命令的问题 |
|
|
|
workdir = os.path.join(currentDir, 'batchPrint', versionId, 'data') |
|
|
|
workdir = os.path.join(folder, 'data') |
|
|
|
download_transform_save_by_json(jsonFilePath, workdir, '') |
|
|
|
download_transform_save_by_json(jsonFilePath, workdir, '') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -144,12 +165,12 @@ def main(work_dir=None): |
|
|
|
shutil.rmtree(objFilePath) |
|
|
|
shutil.rmtree(objFilePath) |
|
|
|
|
|
|
|
|
|
|
|
res = step1(versionId) |
|
|
|
res = step1(versionId) |
|
|
|
if not res: |
|
|
|
if res == False: |
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} JSON文件下载数据失败,等待10秒') |
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} JSON文件下载数据失败,等待10秒') |
|
|
|
time.sleep(10) |
|
|
|
time.sleep(10) |
|
|
|
continue |
|
|
|
continue |
|
|
|
jsonFilePath = os.path.join(currentDir, 'batchPrint', versionId, 'json', f'{versionId}.json') |
|
|
|
jsonFilePath = os.path.join(res, 'json', f'{versionId}.json') |
|
|
|
step2(jsonFilePath, versionId) |
|
|
|
step2(res,res, versionId) |
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 数据处理完成,等待10秒') |
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 数据处理完成,等待10秒') |
|
|
|
|
|
|
|
|
|
|
|
#判断下载的obj文件数量和json里的是否一致,排除arrange文件夹 |
|
|
|
#判断下载的obj文件数量和json里的是否一致,排除arrange文件夹 |
|
|
|
|