一键合并下发功能基本实现,下一步增加扫码一键合并下发功能

This commit is contained in:
mgw
2023-03-16 20:24:44 +08:00
parent 4b82d20f18
commit 2c81aaab1f
4 changed files with 107 additions and 3 deletions

View File

@@ -73,10 +73,21 @@ class UpSelectWizard(models.TransientModel):
# 合并文件
with open(file_path_local, mode='ab+') as file:
file.write(datas)
# 下发成功标识
item.button_state = True
_logger.info('========初次合并成功===============')
_logger.info(file_path_local)
# 去除合并文件中间部分的头尾
with open(file_path_local, mode='rb+') as f:
# _logger.info(f.read())
# content = f.read()
# _logger.info(content)
new_content = f.read().replace(b'\r\nM30\r\n%\r\n%\r\n', b'\r\n')
# _logger.info(new_content)
f.seek(0)
f.truncate()
f.write(new_content)
_logger.info('========二次合并成功===============')
# 存在本地的文件下发到机床
_logger.info("==========存在服务器成功,准备下发===========")
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)