新的信息

This commit is contained in:
dongchangxi committed 2024-09-02 16:52:37 +08:00
1 parent c66fc76e10
commit 345790cb05
51 files changed
+5187 -61

No files matched your search

+10 -1
View File
@@ -49,6 +49,15 @@ mysql_dong = {
"charset": "utf8mb4"
}
mysql_task_rc = {
"host": '172.31.1.254',#"172.16.20.13",
"port": 23306,
"user": "pi",
"password": "ph2008",
"db": "suwa3d",
"charset": "utf8mb4"
}
if platform.system() == 'Windows':
workdir = 'D:\\'
sharedir = 'E:\\'
@@ -115,7 +124,7 @@ r2 = {
#new_make_psids = ['1', '17', '29', '44', '54', '55', '63', '65', '77', '79', '80', '85', '86']
#企业微信通知人员
notify_user_Ids = ["DongZhangXi","YouShui"]
notify_user_Ids = ["DongZhangXi"]
#任务运行超时时间设定 ,单位秒
task_run_timeout = {
+49 -1
View File
@@ -330,4 +330,52 @@ def down_obj_from_oss_for_fix(workdir, pid, action):
# print('正在下载:', file.key)
localfile = os.path.join(workdir, action, pid, filename)
config.oss_bucket.get_object_to_file(file.key, localfile)
return obj_filename
return obj_filename
def down_obj_from_oss_for_repeat_texture(workdir, pid, action):
print(os.path.join(workdir, pid))
if not os.path.exists(os.path.join(workdir, pid)):
print("目录不存在,无法处理")
return "error"
#判断是否有专门新建的目录用来重新贴图
newPath = os.path.join(workdir, pid,'repeat_texture','completion_cloud')
if not os.path.exists(newPath):
os.makedirs(newPath)
# 根据前缀获取文件列表
prefix = f'objs/{action}/{pid}/ai/repeat_texture/completion_cloud'
filelist = oss2.ObjectIteratorV2(config.oss_bucket, prefix=prefix)
print('正在下载:', prefix)
for file in filelist:
filename = file.key.split('/')[-1]
if filename == "":
continue
localfile = os.path.join(newPath, filename)
config.oss_bucket.get_object_to_file(file.key, localfile)
return newPath
def down_obj_from_oss_auto(pid,action,pathStr):
#pathStr = os.path.join(workdir, str(pid)+"_ai")
if not os.path.exists(pathStr):
os.makedirs(pathStr)
# 根据前缀获取文件列表
prefix = f'objs/{action}/{pid}'
filelist = oss2.ObjectIteratorV2(config.oss_bucket, prefix=prefix)
print('正在下载:', prefix)
for file in filelist:
filename = file.key.split('/')[-1]
if filename == "":
continue
if filename != f"{pid}.jpg" and filename != f"{pid}.obj" and filename != f"{pid}.mtl":
continue
print(filename)
localfile = os.path.join(pathStr, filename)
config.oss_bucket.get_object_to_file(file.key, localfile)
+83
View File
@@ -0,0 +1,83 @@
# mysql数据库常用任务函数封装
import pymysql, socket, time
import config
#公共连接库
def pymysqlAlias():
return pymysql.connect(
host=config.mysql_gpu['host'],
port=config.mysql_gpu['port'],
user=config.mysql_gpu['user'],
password=config.mysql_gpu['password'],
db=config.mysql_gpu['db'],
charset=config.mysql_gpu['charset'],)
# 新增新的任务
def add_reapeat_texture_task(data):
try:
resExist = is_exist(data["pid"])
if resExist == True:
return
with pymysqlAlias() as conn:
cursor = conn.cursor()
sql = f'insert into task_repeat_texture (pid,heads,createTime) values ("{data["pid"]}","{data["heads"]}","{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}")'
print(f'sql: {sql}')
cursor.execute(sql)
conn.commit()
except Exception as e:
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行add_task({data})异常: {str(e)}")
#
def is_exist(pid):
try:
with pymysqlAlias() as conn:
cursor = conn.cursor()
sql = f'select count(*) from task_repeat_texture where pid = {pid} and status = 0'
print(f'sql: {sql}')
cursor.execute(sql)
result = cursor.fetchone()
if result[0] > 0:
return True
else:
return False
except Exception as e:
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行is_new_make_psid()异常: {str(e)}")
return "error"
def get_pid_task():
try:
with pymysqlAlias() as conn:
cursor = conn.cursor()
sql = f'select * from task_repeat_texture where status = 1 limit 1'
print(f'sql: {sql}')
cursor.execute(sql)
result = cursor.fetchone()
if result:
return result
else:
return None
except Exception as e:
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行get_pid_task()异常: {str(e)}")
return "error"
#更新状态
def update_status(id,status):
try:
with pymysqlAlias() as conn:
cursor = conn.cursor()
hostname = socket.gethostname()
sql = f'update task_repeat_texture set status = {status},updateTime = now() where id = {id}'
print(f'开始任务sql: {sql}')
cursor.execute(sql)
conn.commit()
except Exception as e:
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} 执行update_status()异常: {str(e)}")
+30
View File
@@ -0,0 +1,30 @@
# mysql数据库常用任务函数封装
import pymysql, socket, time
import config
#公共连接库
def pymysqlAlias():
return pymysql.connect(
host=config.mysql_task_rc['host'],
port=config.mysql_task_rc['port'],
user=config.mysql_task_rc['user'],
password=config.mysql_task_rc['password'],
db=config.mysql_task_rc['db'],
charset=config.mysql_task_rc['charset'],)
# 获取新的任务
def get_task_rc_count():
try:
with pymysqlAlias() as conn:
cursor = conn.cursor()
sql = f'select count(*) from task_distributed where status != 2 and created_at >= "2024-09-02 00:00:00"'
# print(f'sql: {sql}')
cursor.execute(sql)
data = cursor.fetchone()
if data:
return data[0]
else:
return ''
except Exception as e:
print(f"{time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())} get_task_rc_count()异常: {str(e)}")
return ''