下发完成后,关闭ftp连接
This commit is contained in:
@@ -77,8 +77,9 @@ class FtpButton(models.Model):
|
||||
# 存在本地的文件下发到机床
|
||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
_logger.info("======%s下发成功======" % a.display_name)
|
||||
up_time = str(datetime.now())
|
||||
ftp.close_ftp()
|
||||
|
||||
up_time = str(datetime.now())
|
||||
self.env['delivery.record'].create({
|
||||
'workorder_id': self.workorder_id.id,
|
||||
'delivery_type': '单个下发',
|
||||
@@ -296,6 +297,7 @@ class WorkCenterBarcode(models.Model):
|
||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||
_logger.info("======%s下发成功======" % a.display_name)
|
||||
item.button_state = True
|
||||
ftp.close_ftp()
|
||||
# 增加一键下发记录
|
||||
up_time = str(datetime.now())
|
||||
sequence_str = ','.join(sequence_collect)
|
||||
|
||||
@@ -78,6 +78,13 @@ class FtpController:
|
||||
with open(localpath, mode='rb') as file:
|
||||
self.ftp.storbinary('STOR ' + remotepath, file, bufsize)
|
||||
|
||||
# 关闭连接
|
||||
def close_ftp(self):
|
||||
"""
|
||||
下发完成后关闭ftp连接,减少资源损耗
|
||||
"""
|
||||
self.ftp.close()
|
||||
|
||||
|
||||
def delAllfile(self, ftppath):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user