最新版
This commit is contained in:
1 parent
b8f5091514
commit
47bad0c0cb
11 files changed
+100
-31
No files matched your search
+2
-1
@@ -15,7 +15,7 @@ test/test1.py
|
||||
timer/29.zip
|
||||
yj_local_build/main_step1.spec
|
||||
yj_local_build/建模source_code.zip
|
||||
apps/__pycache__/fix_up_color_two_a.cpython-310.pyc
|
||||
apps/__pycache__/
|
||||
apps/__pycache__/ps_image_shadow_up_ag_two_a.cpython-310.pyc
|
||||
apps/__pycache__/white_purification_v3.cpython-310.pyc
|
||||
apps/__pycache__/white_purification_v4.cpython-310.pyc
|
||||
@@ -84,3 +84,4 @@ factory_sliceing/utils/__pycache__/__init__.cpython-311.pyc
|
||||
factory_sliceing/utils/__pycache__/
|
||||
factory_sliceing/auto_sliceing_operate/utils/__pycache__/
|
||||
factory_sliceing/@AutomationLog.txt
|
||||
factory_sliceing/auto_sliceing_operate/utils/__pycache__/logs.cpython-311.pyc
|
||||
@@ -20,11 +20,15 @@ def upLoadSliceFileToOSS(data):
|
||||
print(f"错误:dataFolder 文件夹不存在 - {dataFolder}")
|
||||
exit(1)
|
||||
dataFilePath = ""
|
||||
print(f"开始上传文件: {dataFolder},{os.listdir(dataFolder)}")
|
||||
for file1 in os.listdir(dataFolder):
|
||||
if os.path.isdir(file1):
|
||||
if os.path.isdir(os.path.join(dataFolder,file1)):
|
||||
dataFilePath = os.path.join(dataFolder,file1, 'data.snslc')
|
||||
if os.path.exists(dataFilePath):
|
||||
upload_file(f"slice/complate/{data}/data.snslc", dataFilePath)
|
||||
print(f"开始上传文件: {dataFilePath},文件存在")
|
||||
return upload_file(f"slice/complate/{data}/data.snslc", dataFilePath)
|
||||
print(f"开始上传文件: {dataFilePath},文件不存在")
|
||||
return False
|
||||
|
||||
|
||||
#"C:/test/10192_small_No4/data"
|
||||
@@ -87,12 +91,19 @@ def main(work_dir=None):
|
||||
time.sleep(10)
|
||||
continue
|
||||
data = data.decode('utf-8')
|
||||
# data = "10192_small_No4"
|
||||
# 判断是否是字符串
|
||||
if not isinstance(data, str):
|
||||
log("取出的数据不是字符串")
|
||||
time.sleep(10)
|
||||
continue
|
||||
folderPath = os.path.join(work_dir,"batchPrint", data,"data")
|
||||
# 判断目录是否存在
|
||||
if not os.path.exists(folderPath):
|
||||
log(f"目录不存在: {folderPath}")
|
||||
time.sleep(10)
|
||||
continue
|
||||
|
||||
# data 格式为 batchId_machineType_No machineId
|
||||
batchId = data.split('_')[0] #批次ID
|
||||
# machineType = data.split('_')[1] #机型类型
|
||||
|
||||
@@ -33,24 +33,23 @@ def getCurrentMachineId():
|
||||
return machineId
|
||||
|
||||
def main(work_dir=None):
|
||||
# if work_dir is None:
|
||||
# log("工作目录不能为空")
|
||||
# exit(0)
|
||||
# redis 获取队列中的数据
|
||||
|
||||
downloadPath = cfg('machine.download_path', None)
|
||||
if downloadPath is None:
|
||||
log("工作目录不能为空")
|
||||
exit(0)
|
||||
if not os.path.exists(downloadPath):
|
||||
os.makedirs(downloadPath)
|
||||
|
||||
|
||||
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)
|
||||
data = r.spop('pb:begin_print_machine_'+machineId)
|
||||
if data is None:
|
||||
log("队列为空")
|
||||
time.sleep(10)
|
||||
@@ -63,17 +62,17 @@ def main(work_dir=None):
|
||||
continue
|
||||
# batchId = str(data)
|
||||
ossZipPath = f'slice/complate/{data}/data.snslc'
|
||||
localPath = os.path.join(downloadPath, f'data.snslc')
|
||||
localPath = os.path.join(downloadPath,data, f'data.snslc')
|
||||
# 判断目录是否存在,不存在就创建
|
||||
if not os.path.exists(os.path.join(downloadPath)):
|
||||
os.makedirs(os.path.join(downloadPath))
|
||||
else:
|
||||
# 删除目录下的所有文件
|
||||
for file in os.listdir(os.path.join(downloadPath)):
|
||||
os.remove(os.path.join(downloadPath, file))
|
||||
|
||||
# 删除目录下指定文件,如果存在
|
||||
if os.path.exists(os.path.join(downloadPath,data, f'data.snslc')):
|
||||
os.remove(os.path.join(downloadPath,data, f'data.snslc'))
|
||||
# 下载 zip 文件
|
||||
downloadZip(ossZipPath, localPath)
|
||||
th, localPath)
|
||||
# # 解压 zip 文件
|
||||
# localUnzipPath = os.path.join(work_dir,batchId)
|
||||
# unzip(localZipPath, localUnzipPath)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
from .utils.miniIo import upload_file
|
||||
|
||||
|
||||
# 测试上传文件
|
||||
def test_upload_file():
|
||||
upload_file("test.txt", "test.txt")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_upload_file()
|
||||
@@ -0,0 +1 @@
|
||||
AAAAAAAAAAA
|
||||
@@ -15,7 +15,7 @@ def get_bucket_name():
|
||||
global _bucket_name
|
||||
if _bucket_name is None:
|
||||
# 优先从配置文件读取,如果没有则从环境变量读取,最后使用默认值
|
||||
_bucket_name = cfg('minio.bucket', None) or os.getenv('MINIO_BUCKET', 'default-bucket')
|
||||
_bucket_name = cfg('minio.bucket', None)
|
||||
log(f"MiniIO 存储桶名称: {_bucket_name}")
|
||||
return _bucket_name
|
||||
|
||||
@@ -33,10 +33,17 @@ class MiniIOClientSingleton:
|
||||
if self._client is None:
|
||||
# MiniIO 连接配置
|
||||
# 可以从环境变量或配置文件中读取
|
||||
endpoint = os.getenv('MINIO_ENDPOINT', 'localhost:9000')
|
||||
access_key = os.getenv('MINIO_ACCESS_KEY', 'minioadmin')
|
||||
secret_key = os.getenv('MINIO_SECRET_KEY', 'minioadmin')
|
||||
secure = os.getenv('MINIO_SECURE', 'False').lower() == 'true'
|
||||
endpoint = cfg('minio.endpoint', 'localhost:9000')
|
||||
access_key = cfg('minio.access_key', 'minioadmin')
|
||||
secret_key = cfg('minio.secret_key', 'minioadmin')
|
||||
# secure 参数:True 使用 HTTPS,False 使用 HTTP
|
||||
# 从配置文件读取,如果没有配置则默认为 False(HTTP)
|
||||
secure_config = cfg('minio.secure', False)
|
||||
# 确保是布尔值(处理字符串 'true'/'false' 的情况)
|
||||
if isinstance(secure_config, str):
|
||||
secure = secure_config.lower() in ('true', '1', 'yes')
|
||||
else:
|
||||
secure = bool(secure_config)
|
||||
|
||||
try:
|
||||
self._client = Minio(
|
||||
@@ -45,9 +52,16 @@ class MiniIOClientSingleton:
|
||||
secret_key=secret_key,
|
||||
secure=secure
|
||||
)
|
||||
log(f"MiniIO 客户端初始化成功: {endpoint}")
|
||||
log(f"MiniIO 客户端初始化成功: {endpoint} (secure={secure})")
|
||||
except Exception as e:
|
||||
log(f"MiniIO 客户端初始化失败: {str(e)}")
|
||||
error_msg = str(e)
|
||||
# 检查是否是端口错误
|
||||
if "API port" in error_msg or "InvalidArgument" in error_msg:
|
||||
log(f"MiniIO 连接失败: 请确保使用的是 API 端口(通常是 9000),而不是 Console 端口(通常是 9001)")
|
||||
log(f"当前配置的 endpoint: {endpoint}")
|
||||
log(f"错误详情: {error_msg}")
|
||||
else:
|
||||
log(f"MiniIO 客户端初始化失败: {error_msg}")
|
||||
raise
|
||||
return self._client
|
||||
|
||||
|
||||
@@ -23,6 +23,15 @@ access_key_secret = "8ywTDF9upPAtvgXtLKALY2iMYHIxdS"
|
||||
endpoint = "oss-cn-shanghai.aliyuncs.com"
|
||||
bucket = "suwa3d-securedata"
|
||||
|
||||
#minio
|
||||
[minio]
|
||||
bucket="slicedata"
|
||||
# endpoint 必须使用 API 端口(通常是 9000),不是 Console 端口(通常是 9001)
|
||||
# Console 端口用于 Web 管理界面,API 端口用于 S3 API 操作
|
||||
endpoint="192.168.10.102:9000"
|
||||
access_key="minio"
|
||||
secret_key="MinIO@suwa3d2025."
|
||||
|
||||
# API 配置
|
||||
[api]
|
||||
base_url = "https://mp.api.suwa3d.com"
|
||||
@@ -44,5 +53,5 @@ small_exe = "C:/Users/Administrator/print_factory_type_setting/software/小机
|
||||
|
||||
#机器编号
|
||||
[machine]
|
||||
id=1
|
||||
download_path = ""
|
||||
id="4"
|
||||
download_path = "C://work/batchPrintSlice"
|
||||
@@ -11,11 +11,11 @@ if __name__ == '__main__':
|
||||
command_handlers = {
|
||||
'batch_download': main_download_batch_data_and_trans.main,
|
||||
'begin_sliceing': main_begin_sliceing.main,
|
||||
'download_zip': main_download_zip.main,
|
||||
'download_slice': main_download_zip.main,
|
||||
}
|
||||
|
||||
# 检查参数数量
|
||||
if len(sys.argv) < 2 and sys.argv[1] != 'download_zip':
|
||||
if len(sys.argv) < 2 and sys.argv[1] != 'download_slice':
|
||||
print('Usage: python main.py <command> [work_dir]')
|
||||
print('可用命令:', ' | '.join(command_handlers.keys()))
|
||||
print('\n注意: work_dir 参数可选,如果未提供将从配置文件读取默认值')
|
||||
@@ -30,7 +30,9 @@ if __name__ == '__main__':
|
||||
sys.exit(1)
|
||||
|
||||
# 获取工作目录:优先使用命令行参数,其次使用配置文件,最后使用 None
|
||||
work_dir = sys.argv[2]
|
||||
work_dir = None
|
||||
if len(sys.argv) > 2:
|
||||
work_dir = sys.argv[2]
|
||||
|
||||
# 打印配置信息(可选,用于调试)
|
||||
if cfg('log.level', 'INFO') == 'DEBUG':
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
from auto_sliceing_operate.utils.miniIo import upload_file,check_file_exists,delete_file,download_file
|
||||
|
||||
# 测试上传文件
|
||||
def test_upload_file():
|
||||
upload_file("test.txt", "test.txt")
|
||||
|
||||
# 测试下载文件
|
||||
def test_download_file():
|
||||
download_file("test.txt", "testAAA.txt")
|
||||
|
||||
# 测试删除文件
|
||||
def test_delete_file():
|
||||
delete_file("test.txt")
|
||||
|
||||
# 测试检查文件是否存在
|
||||
def test_check_file_exists():
|
||||
print(check_file_exists("test.txt"))
|
||||
|
||||
|
||||
test_download_file()
|
||||
@@ -0,0 +1 @@
|
||||
AAAAAAAAAAA
|
||||
@@ -0,0 +1 @@
|
||||
AAAAAAAAAAA
|
||||
Reference in new issue
Block a user