Browse Source

bug 修改

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

33
tools/downxmps.py

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

5
tools/gen_xmps.py

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

Loading…
Cancel
Save