bug 修改
This commit is contained in:
1 parent
c0380d2638
commit
fc9e18ec62
2 files changed
+50
-3
No files matched your search
@@ -0,0 +1,47 @@
|
|||||||
|
import platform,sys,redis,time
|
||||||
|
if platform.system() == 'Windows':
|
||||||
|
sys.path.append('e:\\libs\\')
|
||||||
|
else:
|
||||||
|
sys.path.append('/data/deploy/make3d/make2/libs/')
|
||||||
|
|
||||||
|
import config,libs,libs_db
|
||||||
|
|
||||||
|
def getPSid(pid):
|
||||||
|
res = request.get("https://mp.api.suwa3d.com/api/customerP3dLog/photoStudio",params={"pid":pid})
|
||||||
|
res = json.loads(res.text)
|
||||||
|
return str(res['data'])
|
||||||
|
|
||||||
|
def readTask(r,key):
|
||||||
|
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+"-读取队列-"+key)
|
||||||
|
if r.llen('model:'+key) == 0:
|
||||||
|
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+"-没有查询到任务在"+key+"队列中")
|
||||||
|
return
|
||||||
|
#读取一个值
|
||||||
|
pid = r.lpop('model:'+key)
|
||||||
|
#判断是否为空
|
||||||
|
if pid is None:
|
||||||
|
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+"-读取的PID为空")
|
||||||
|
return
|
||||||
|
pid = pid.decode('utf-8')
|
||||||
|
#判断是否走新的建模系统
|
||||||
|
if libs_db.is_new_make_psid(pid) == False:
|
||||||
|
#如果不是走新的建模系统就塞回原来的队列
|
||||||
|
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+"-该任务不是走新的建模任务,塞回原来的队列-"+pid)
|
||||||
|
r.rpush('model:'+key,pid)
|
||||||
|
return
|
||||||
|
#新的建模系统
|
||||||
|
psid = getPSid(pid)
|
||||||
|
libs_db.add_task({"task_type":key,"task_key":pid,"psid":psid})
|
||||||
|
|
||||||
|
#程序主入口
|
||||||
|
if __name__ == '__main__':
|
||||||
|
r = redis.Redis(host="106.14.158.208",password="kcV2000",port=6379,db=6)
|
||||||
|
#开启死循环
|
||||||
|
while True:
|
||||||
|
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+"-读取redis中的任务")
|
||||||
|
# 3D相册建模队列 model:make_experience
|
||||||
|
# model:make model:make10
|
||||||
|
readTask(r,'make10')
|
||||||
|
# time.sleep(2)
|
||||||
|
readTask(r,'make')
|
||||||
|
time.sleep(2)
|
||||||
+3
-3
@@ -9,17 +9,17 @@ import config, libs, libs_db
|
|||||||
|
|
||||||
def upload_xmp(pid):
|
def upload_xmp(pid):
|
||||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 上传xmp文件之前先删除oss上的xmp文件所在目录...')
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 上传xmp文件之前先删除oss上的xmp文件所在目录...')
|
||||||
|
psid = libs.getPSid(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/{psid}/')
|
||||||
if not any(object_list):
|
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()
|
||||||
workdir = os.path.join(config.workdir, pid)
|
workdir = os.path.join(config.workdir, pid)
|
||||||
psid = libs.getPSid(pid)
|
##psid = libs.getPSid(pid)
|
||||||
config.oss_bucket.put_object_from_file(f'xmps/{psid}/{psid}.rcbox', os.path.join(workdir, f'{pid}.rcbox'))
|
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')):
|
for xmp in os.listdir(os.path.join(workdir, 'photo1')):
|
||||||
if xmp.endswith('.xmp'):
|
if xmp.endswith('.xmp'):
|
||||||
|
|||||||
Reference in new issue
Block a user