数据库代码抽离,增加影棚ID

This commit is contained in:
dongchangxi committed 2023-10-14 15:49:37 +08:00
1 parent 7ac055e796
commit abca8a3cfc
10 files changed
+527 -327

No files matched your search

+16 -8
View File
@@ -2,10 +2,10 @@ import os, sys, time, shutil, subprocess, shlex
import platform
if platform.system() == 'Windows':
sys.path.append('e:\\libs\\')
#sys.path.append('libs')
else:
sys.path.append('/data/deploy/make3d/make2/libs/')
from logic import logic_main_service
import config, libs, libs_db
import config, libs, libs_db,common,main_service_db
def load_model(pid):
cmd = f'{config.rcbin} {config.r1["init"]} -load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}"'
@@ -23,7 +23,7 @@ def get_rcver():
def make3d(pid):
simplify_value = 1000000 * libs.getHeadCount(pid)
add_photo3 = ' '
if os.path.exists(os.path.join(config.workdir, pid, 'photo3')):
if common.task_need_photo3(pid):
add_photo3 = ' -addFolder "' + os.path.join(config.workdir, pid, 'photo3') + '" -align -align '
if get_rcver() == 1: # old version
@@ -44,13 +44,14 @@ def make3d(pid):
cmd = f'{config.rcbin} {config.r1["init"]} -load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -update \
-setReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
-mvs -modelSelectMaximalConnectedComponent -modelInvertSelection -modelRemoveSelectedTriangles -closeHoles -clean -simplify {simplify_value} -smooth -unwrap -calculateTexture -renameModel {pid} -exportModel "{pid} {os.path.join(config.workdir, pid, "output", f"{pid}.obj")}" "d:\\make2\\config\\ModelExportParams102.xml" -quit'
-mvs -modelSelectMaximalConnectedComponent -modelInvertSelection -modelRemoveSelectedTriangles -closeHoles -clean -simplify {simplify_value} -smooth -unwrap -calculateTexture -renameModel {pid} -exportModel "{pid}" "{os.path.join(config.workdir, pid, "output", f"{pid}.obj")}" "d:\\make2\\config\\ModelExportParams102.xml" -quit'
print(cmd)
cmd = shlex.split(cmd)
res = subprocess.run(cmd)
else: # new version
if libs.aliyun_face(pid) and libs.get_ps_type(pid) == 1:
calulate_type = 'calculateHighModel'
#判断是否要进行高精模
if common.task_need_high_model(pid):
calulate_type = 'calculateHighModel'
else:
calulate_type = 'calculateNormalModel'
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
@@ -65,11 +66,18 @@ def make3d(pid):
def step2(pid,task_distributed_id=""):
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 开始建模任务step2')
#判断是否要从共享目录拷贝数据
if os.path.exists(os.path.join(config.sharedir, pid)) and not os.path.exists(os.path.join(config.workdir, pid)):
shutil.move(os.path.join(config.sharedir, pid), config.workdir)
else:
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 目录{os.path.join(config.sharedir, pid)}不存在,或{os.path.join(config.workdir, pid)}已存在')
# return
# return
#最后还是要判断有没有存在目录
if not os.path.exists(os.path.join(config.workdir, pid)):
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 目录{os.path.join(config.workdir, pid)}不存在')
return
start_time = time.time()
make3d(pid)
@@ -78,7 +86,7 @@ def step2(pid,task_distributed_id=""):
if task_distributed_id == "":
os.system(f'python d:\\make2\\main_step3.py {pid}')
else:
logic_main_service.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
main_service_db.update_task_distributed_detail({"task_distributed_id":task_distributed_id,"finished_at":time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())})
return
def main(pid):