You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
2.2 KiB
56 lines
2.2 KiB
import os, sys, bpy, time |
|
import platform |
|
if platform.system() == 'Windows': |
|
sys.path.append('e:\\libs\\') |
|
else: |
|
sys.path.append('/data/deploy/make3d/make2/libs/') |
|
|
|
import config, libs, libs_db |
|
|
|
def upload_3d(pid): |
|
start_time = time.time() |
|
workdir = os.path.join(config.workdir, '3d') |
|
|
|
glb_filename = os.path.join(workdir, pid, f'{pid}_decimate.glb') |
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {glb_filename} 开始处理...') |
|
if os.path.exists(glb_filename): |
|
config.oss_bucket.put_object_from_file(f'glbs/3d/{pid}.glb', glb_filename) |
|
# break |
|
os.remove(glb_filename) |
|
else: |
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {glb_filename} 文件不存在,跳过') |
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} glb文件上传完成,共费时{time.time() - start_time}秒') |
|
|
|
def upload_xmp(pid): |
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 上传xmp文件之前先删除oss上的xmp文件所在目录...') |
|
config.oss_bucket.delete_object(f'xmps/{pid}/') |
|
start_time = time.time() |
|
workdir = os.path.join(config.workdir, pid) |
|
psid = libs.getPSid(pid) |
|
config.oss_bucket.put_object_from_file(f'xmps/{psid}/{psid}.rcbox', os.path.join(workdir, f'{pid}.rcbox')) |
|
for xmp in os.listdir(os.path.join(workdir, 'photo1')): |
|
if xmp.endswith('.xmp'): |
|
config.oss_bucket.put_object_from_file(f'xmps/{psid}/mesh/{xmp}', os.path.join(workdir, 'photo1', xmp)) |
|
for xmp in os.listdir(os.path.join(workdir, 'photo2')): |
|
if xmp.endswith('.xmp'): |
|
config.oss_bucket.put_object_from_file(f'xmps/{psid}/texture/{xmp}', os.path.join(workdir, 'photo2', xmp)) |
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} xmp文件上传完成,共费时{time.time() - start_time}秒') |
|
|
|
def main(): |
|
pass |
|
|
|
if __name__ == '__main__': |
|
if len(sys.argv) == 3: |
|
action = sys.argv[1] |
|
pids = sys.argv[2] |
|
else: |
|
print(f'useage: python {sys.argv[0]} [3d|xmp] pid1,pid2,pid3') |
|
sys.exit(1) |
|
|
|
for pid in pids.split(','): |
|
if action == '3d': |
|
upload_3d(pid) |
|
elif action == 'xmp': |
|
upload_xmp(pid) |