4567789
This commit is contained in:
1 parent
bac04def8e
commit
160a06bdb6
7 files changed
+106
-31
No files matched your search
@@ -10,7 +10,7 @@ from .utils.request import requestApiToUpdateSliceStatusComplate
|
||||
from utils.config import cfg
|
||||
|
||||
|
||||
def upLoadSliceFileToOSS(folderPath):
|
||||
def upLoadSliceFileToOSS(data):
|
||||
exe_path = cfg('exe.small_exe', None)
|
||||
if not exe_path:
|
||||
print(f"错误:exe_path 未配置")
|
||||
@@ -24,7 +24,7 @@ def upLoadSliceFileToOSS(folderPath):
|
||||
if os.path.isdir(file1):
|
||||
dataFilePath = os.path.join(dataFolder,file1, 'data.snslc')
|
||||
if os.path.exists(dataFilePath):
|
||||
upload_file(f"complatte/slice/{folderPath}/data.snslc", dataFilePath)
|
||||
upload_file(f"slice/complate/{data}/data.snslc", dataFilePath)
|
||||
|
||||
|
||||
#"C:/test/10192_small_No4/data"
|
||||
@@ -59,7 +59,7 @@ def BeginSliceing(batchId,machineId, folderPath,data):
|
||||
# 开启死循环,判断文件是否全部导入成功
|
||||
log("切片结束")
|
||||
time.sleep(5)
|
||||
res = upLoadSliceFileToOSS(folderPath)
|
||||
res = upLoadSliceFileToOSS(data)
|
||||
if not res:
|
||||
print("上传切片文件失败")
|
||||
exit(1)
|
||||
@@ -67,7 +67,7 @@ def BeginSliceing(batchId,machineId, folderPath,data):
|
||||
# requestApiToUpdateSliceStatusComplate(batchId, 0)
|
||||
# sadd 插入对应的队列
|
||||
r = redisClient()
|
||||
r.sadd('pb:begin_print_machine_'+machineId, batchId)
|
||||
r.sadd('pb:begin_print_machine_'+machineId, data)
|
||||
|
||||
def main(work_dir=None):
|
||||
r = redisClient()
|
||||
|
||||
@@ -3,7 +3,7 @@ import zipfile,time
|
||||
import os
|
||||
from .utils.oss_redis import redisClient
|
||||
from .utils.logs import log
|
||||
|
||||
from utils.config import cfg
|
||||
# 打印机旁边的电脑下载切片文件到本地
|
||||
# 解压压缩包,将数据移动到指定的目录
|
||||
#
|
||||
@@ -26,19 +26,29 @@ def unzip(localZipPath, localUnzipPath):
|
||||
|
||||
def getCurrentMachineId():
|
||||
# 获取当前电脑的id
|
||||
return "1"
|
||||
|
||||
machineId = cfg('machine.id', None)
|
||||
if machineId is None:
|
||||
log("获取当前电脑id失败")
|
||||
exit(0)
|
||||
return machineId
|
||||
|
||||
def main(work_dir=None):
|
||||
if work_dir is None:
|
||||
log("工作目录不能为空")
|
||||
exit(0)
|
||||
# if work_dir is None:
|
||||
# log("工作目录不能为空")
|
||||
# exit(0)
|
||||
# redis 获取队列中的数据
|
||||
r = redisClient()
|
||||
machineId = getCurrentMachineId()
|
||||
if machineId is None:
|
||||
log("获取当前电脑id失败")
|
||||
exit(0)
|
||||
|
||||
downloadPath = cfg('machine.download_path', None)
|
||||
if downloadPath is None:
|
||||
log("数据存放路径失败没有设置")
|
||||
exit(0)
|
||||
|
||||
|
||||
while True:
|
||||
data = r.lpop('pb:begin_print_machine_'+machineId)
|
||||
if data is None:
|
||||
@@ -47,24 +57,24 @@ def main(work_dir=None):
|
||||
continue
|
||||
data = data.decode('utf-8')
|
||||
# 判断是否是数字
|
||||
if not data.isdigit():
|
||||
log("取出的数据不是数字")
|
||||
if data.isdigit():
|
||||
log("取出的数据是数字")
|
||||
time.sleep(10)
|
||||
continue
|
||||
batchId = str(data)
|
||||
ossZipPath = f'data/slice/{batchId}.zip'
|
||||
localZipPath = os.path.join(work_dir,batchId, f'{batchId}.zip')
|
||||
# batchId = str(data)
|
||||
ossZipPath = f'slice/complate/{data}/data.snslc'
|
||||
localPath = os.path.join(downloadPath, f'data.snslc')
|
||||
# 判断目录是否存在,不存在就创建
|
||||
if not os.path.exists(os.path.join(work_dir,batchId)):
|
||||
os.makedirs(os.path.join(work_dir,batchId))
|
||||
if not os.path.exists(os.path.join(downloadPath)):
|
||||
os.makedirs(os.path.join(downloadPath))
|
||||
else:
|
||||
# 删除目录下的所有文件
|
||||
for file in os.listdir(os.path.join(work_dir,batchId)):
|
||||
os.remove(os.path.join(work_dir,batchId, file))
|
||||
for file in os.listdir(os.path.join(downloadPath)):
|
||||
os.remove(os.path.join(downloadPath, file))
|
||||
|
||||
# 下载 zip 文件
|
||||
downloadZip(ossZipPath, localZipPath)
|
||||
# 解压 zip 文件
|
||||
localUnzipPath = os.path.join(work_dir,batchId)
|
||||
unzip(localZipPath, localUnzipPath)
|
||||
# 触发打印处理
|
||||
downloadZip(ossZipPath, localPath)
|
||||
# # 解压 zip 文件
|
||||
# localUnzipPath = os.path.join(work_dir,batchId)
|
||||
# unzip(localZipPath, localUnzipPath)
|
||||
# # 触发打印处理
|
||||
Reference in new issue
Block a user