修正合并下发bug
This commit is contained in:
@@ -26,7 +26,18 @@ class UpSelectWizard(models.TransientModel):
|
||||
|
||||
|
||||
def confirm_up(self):
|
||||
|
||||
# 合并下发前删除机床上的全部程序
|
||||
try:
|
||||
filepath = '/nc2machine'
|
||||
del_list = os.listdir(filepath)
|
||||
_logger.info("=====================================%s" % del_list)
|
||||
for f in del_list:
|
||||
file_path = os.path.join(filepath, f)
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
except Exception as e:
|
||||
_logger.info("=====================================", e)
|
||||
raise UserError('程序删除失败,请重试')
|
||||
host = self.workcenter_id.machine_tool_id.ftp_host
|
||||
port = self.workcenter_id.machine_tool_id.ftp_port
|
||||
username = self.workcenter_id.machine_tool_id.ftp_num
|
||||
@@ -35,6 +46,8 @@ class UpSelectWizard(models.TransientModel):
|
||||
print(host, port, username, pwd, remote_path)
|
||||
ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||
sequence_collect = []
|
||||
file_path_local = ''
|
||||
file_path_remote = ''
|
||||
try:
|
||||
# 给文件名
|
||||
begin_name1 = self.program_ids[0].cnc_id.display_name.split('-')
|
||||
@@ -61,12 +74,12 @@ class UpSelectWizard(models.TransientModel):
|
||||
with open(file_path_local, mode='ab+') as file:
|
||||
file.write(datas)
|
||||
|
||||
# 存在本地的文件下发到机床
|
||||
_logger.info("==========存在服务器成功,准备下发===========")
|
||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
_logger.info("======%s下发成功======" % a.display_name)
|
||||
# 下发成功标识
|
||||
item.button_state = True
|
||||
|
||||
# 存在本地的文件下发到机床
|
||||
_logger.info("==========存在服务器成功,准备下发===========")
|
||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
ftp.close_ftp()
|
||||
|
||||
up_time = str(datetime.now())
|
||||
@@ -78,6 +91,8 @@ class UpSelectWizard(models.TransientModel):
|
||||
})
|
||||
_logger.info("==============合并下发成功==============")
|
||||
except Exception as e:
|
||||
for item in self.program_ids:
|
||||
item.button_state = False
|
||||
_logger.info("=====================================", e)
|
||||
raise UserError('NC下发执行超时, 请检查下发状态')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user