合并下发功能已完成,待测试
This commit is contained in:
@@ -28,14 +28,13 @@ class UpSelectWizard(models.TransientModel):
|
|||||||
|
|
||||||
def confirm_up(self):
|
def confirm_up(self):
|
||||||
|
|
||||||
|
|
||||||
host = self.workcenter_id.machine_tool_id.ftp_host
|
host = self.workcenter_id.machine_tool_id.ftp_host
|
||||||
port = self.workcenter_id.machine_tool_id.ftp_port
|
port = self.workcenter_id.machine_tool_id.ftp_port
|
||||||
username = self.workcenter_id.machine_tool_id.ftp_num
|
username = self.workcenter_id.machine_tool_id.ftp_num
|
||||||
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
|
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
|
||||||
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
|
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
|
||||||
print(host, port, username, pwd, remote_path)
|
print(host, port, username, pwd, remote_path)
|
||||||
# ftp = ftp_operate.FtpController(host, port, username, pwd)
|
ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||||
try:
|
try:
|
||||||
# 给文件名
|
# 给文件名
|
||||||
begin_name1 = self.program_ids[0].cnc_id.display_name.split('-')
|
begin_name1 = self.program_ids[0].cnc_id.display_name.split('-')
|
||||||
@@ -52,22 +51,23 @@ class UpSelectWizard(models.TransientModel):
|
|||||||
_logger.info(a.display_name)
|
_logger.info(a.display_name)
|
||||||
datas = base64.standard_b64decode(a.datas)
|
datas = base64.standard_b64decode(a.datas)
|
||||||
# print(datas)
|
# print(datas)
|
||||||
# file_path_local = '{}/{}'.format('/nc2machine', final_name)
|
file_path_local = '{}/{}'.format('/nc2machine', final_name)
|
||||||
# print(file_path_local)
|
# print(file_path_local)
|
||||||
|
|
||||||
# 本地测试合并下发
|
# 本地测试合并下发
|
||||||
file_path_local = '{}/{}'.format('D:\\jikimo', a.display_name)
|
# file_path_local = '{}/{}'.format('D:\\jikimo', a.display_name)
|
||||||
# file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name)
|
# file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name)
|
||||||
# file_path_remote = '{}\{}'.format(remote_path, a.display_name)
|
file_path_remote = '{}\{}'.format(remote_path, final_name)
|
||||||
# 合并文件
|
# 合并文件
|
||||||
with open(file_path_local, mode='wb+') as file:
|
with open(file_path_local, mode='ab+') as file:
|
||||||
file.write(datas)
|
file.write(datas)
|
||||||
|
|
||||||
# 存在本地的文件下发到机床
|
# 存在本地的文件下发到机床
|
||||||
# _logger.info("=====================11================")
|
_logger.info("==========存在服务器成功,准备下发===========")
|
||||||
# # ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||||
# item.button_state = True
|
# 下发成功标识
|
||||||
# _logger.info("=====================22================")
|
item.button_state = True
|
||||||
|
_logger.info("==============合并下发成功==============")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.info("=====================================", e)
|
_logger.info("=====================================", e)
|
||||||
raise UserError('NC下发执行超时, 请检查下发状态')
|
raise UserError('NC下发执行超时, 请检查下发状态')
|
||||||
|
|||||||
Reference in New Issue
Block a user