Browse Source

bug 修改

master
dongchangxi 2 years ago
parent
commit
9209b9879c
  1. 31
      tools/downxmps.py
  2. 3
      tools/gen_xmps.py

31
tools/downxmps.py

@ -7,7 +7,7 @@ else:
import config, libs, libs_db import config, libs, libs_db
def down_xmps_from_oss(psid,pid = ""): def down_xmps_from_oss(psid):
def need_down(): def need_down():
filename = f'xmps/{psid}/{psid}.rcbox' filename = f'xmps/{psid}/{psid}.rcbox'
if not config.oss_bucket.object_exists(filename): if not config.oss_bucket.object_exists(filename):
@ -32,12 +32,7 @@ def down_xmps_from_oss(psid,pid = ""):
config.oss_bucket.get_object_to_file(filename, local_file) config.oss_bucket.get_object_to_file(filename, local_file)
return True return True
#在有pid 的情况下判断是否要从云端下载影棚坐标文件
if pid != "":
if local_and_remote_file_time(psid,pid) == "local_file_best_new":
print("本地的文件最新,不需要下载云端影棚坐标文件")
return
else:
if not need_down(): return if not need_down(): return
print('正在下载影棚坐标文件') print('正在下载影棚坐标文件')
@ -65,6 +60,12 @@ def down_xmps_from_oss(psid,pid = ""):
print('正在下载:', file.key) print('正在下载:', file.key)
config.oss_bucket.get_object_to_file(file.key, os.path.join(dest_path, 'texture', filename)) config.oss_bucket.get_object_to_file(file.key, os.path.join(dest_path, 'texture', filename))
#下载rcbox文件
print("下载rcbox文件")
filename_rcbox = f'xmps/{psid}/{psid}.rcbox'
local_file_rcbox = os.path.join(config_path, 'xmps', psid, f'{psid}.rcbox')
config.oss_bucket.get_object_to_file(filename_rcbox, local_file_rcbox)
print('下载完成') print('下载完成')
@ -72,12 +73,12 @@ def down_xmps_from_oss(psid,pid = ""):
def local_and_remote_file_time(psid,pid): def local_and_remote_file_time(psid,pid):
#远程文件的路径 #远程文件的路径
config_path = os.path.join(config.sharedir, 'libs') config_path = os.path.join(config.sharedir, 'libs')
xmps_mesh_path = os.path.join(config_path, 'xmps', psid, 'mesh') xmps_mesh_path = os.path.join(config_path, 'xmps', psid)
remotefile = os.path.join(xmps_mesh_path, '11_1.xmp') remotefile = os.path.join(xmps_mesh_path, f'{psid}.rcbox')
#本地文件的路劲 #本地文件的路劲
input_path = os.path.join(config.workdir, pid) input_path = os.path.join(config.workdir, pid)
ImagesGeometry = os.path.join(input_path, "photo1") ImagesGeometry = os.path.join(input_path)
localfile = os.path.join(ImagesGeometry, '11_1.xmp') localfile = os.path.join(ImagesGeometry, f'{pid}.rcbox')
print(f'比对本地文件和远程文件的时间先后--remotefile: {remotefile}, localfile: {localfile}') print(f'比对本地文件和远程文件的时间先后--remotefile: {remotefile}, localfile: {localfile}')
if os.path.exists(localfile): if os.path.exists(localfile):
remotefile_last_modified = os.path.getmtime(remotefile) remotefile_last_modified = os.path.getmtime(remotefile)
@ -103,17 +104,19 @@ if __name__ == '__main__':
exit(1) exit(1)
for pid in pids.split(','): for pid in pids.split(','):
#本地的路径
input_path = os.path.join(config.workdir, pid) input_path = os.path.join(config.workdir, pid)
ImagesGeometry = os.path.join(input_path, "photo1") ImagesGeometry = os.path.join(input_path, "photo1")
ImagesTexture = os.path.join(input_path, "photo2") ImagesTexture = os.path.join(input_path, "photo2")
#共享盘上的路径
psid = libs.getPSid(pid) psid = libs.getPSid(pid)
config_path = os.path.join(config.sharedir, 'libs') config_path = os.path.join(config.sharedir, 'libs')
xmps_mesh_path = os.path.join(config_path, 'xmps', psid, 'mesh') xmps_mesh_path = os.path.join(config_path, 'xmps', psid, 'mesh')
xmps_texture_path = os.path.join(config_path, 'xmps', psid, 'texture') xmps_texture_path = os.path.join(config_path, 'xmps', psid, 'texture')
# 从oss下载影棚坐标文件 # 从oss下载影棚坐标文件
down_xmps_from_oss(psid,pid) down_xmps_from_oss(psid)
# 根据坐标文件时间戳判断是否需要更新 # 根据坐标文件时间戳判断是否需要更新
if local_and_remote_file_time(psid,pid) == "local_file_best_new": if local_and_remote_file_time(psid,pid) == "local_file_best_new":
@ -130,6 +133,6 @@ if __name__ == '__main__':
# continue # continue
print(f'正在更新{pid}号影棚坐标文件') print(f'正在更新{pid}号影棚坐标文件')
os.system('xcopy /y /q ' + xmps_mesh_path + '*.* ' + ImagesGeometry) os.system('xcopy /y /q ' + xmps_mesh_path + '\*.* ' + ImagesGeometry)
os.system('xcopy /y /q ' + xmps_texture_path + '*.* ' + ImagesTexture) os.system('xcopy /y /q ' + xmps_texture_path + '\*.* ' + ImagesTexture)

3
tools/gen_xmps.py

@ -1,4 +1,4 @@
import os, sys, time, shutil, subprocess, shlex, json import os, sys, time, shutil, subprocess, shlex, json,oss2
import platform import platform
if platform.system() == 'Windows': if platform.system() == 'Windows':
sys.path.append('e:\\libs\\') sys.path.append('e:\\libs\\')
@ -14,6 +14,7 @@ def upload_xmp(pid):
#config.oss_bucket.delete_object(f'xmps/{pid}/') #config.oss_bucket.delete_object(f'xmps/{pid}/')
#删除oss 上的文件夹里的内容 #删除oss 上的文件夹里的内容
object_list = oss2.ObjectIterator(config.oss_bucket, prefix=f'xmps/{pid}/') object_list = oss2.ObjectIterator(config.oss_bucket, prefix=f'xmps/{pid}/')
if not any(object_list):
config.oss_bucket.batch_delete_objects([obj.key for obj in object_list]) config.oss_bucket.batch_delete_objects([obj.key for obj in object_list])
start_time = time.time() start_time = time.time()

Loading…
Cancel
Save