优化ftp路径
This commit is contained in:
@@ -815,7 +815,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
production_no_ftp = reportpath.split('/')
|
||||
production_no = workorder.production_id.name.replace('/', '_')
|
||||
# ftp地址
|
||||
remotepath = os.path.join('/', production_no_ftp[1], 'detection')
|
||||
remotepath = os.path.join('/home/ftp/ftp_root/NC', production_no_ftp[1], 'detection')
|
||||
logging.info('ftp地址:%s' % remotepath)
|
||||
if reportpath.find(production_no) != -1:
|
||||
# 服务器内临时地址
|
||||
@@ -894,7 +894,7 @@ class CNCprocessing(models.Model):
|
||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
||||
'estimated_processing_time': obj['estimated_processing_time'],
|
||||
'remark': obj['remark'],
|
||||
'program_path': program_path.replace('/tmp', '')
|
||||
'program_path': program_path.replace('/tmp', '/home/ftp/ftp_root/NC')
|
||||
})
|
||||
cnc_processing.get_cnc_processing_file(program_path_tmp, cnc_processing, program_path)
|
||||
# cnc_workorder.state = 'done'
|
||||
@@ -933,7 +933,7 @@ class CNCprocessing(models.Model):
|
||||
|
||||
# 将FTP的nc文件下载到临时目录
|
||||
def download_file_tmp(self, production_no, processing_panel):
|
||||
remotepath = os.path.join('/', production_no, 'return', processing_panel)
|
||||
remotepath = os.path.join('/home/ftp/ftp_root/NC', production_no, 'return', processing_panel)
|
||||
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
|
||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
|
||||
|
||||
@@ -37,8 +37,22 @@ class FtpController():
|
||||
os.makedirs(serverdir)
|
||||
try:
|
||||
logging.info("进入FTP目录 ")
|
||||
self.ftp.cwd(target_dir) # 切换工作路径
|
||||
logging.info('FTP目录:%s' % target_dir)
|
||||
logging.info('目录:%s' % target_dir)
|
||||
target_dir1 = target_dir.split('/')
|
||||
logging.info('目录1:%s' % target_dir1[1])
|
||||
self.ftp.cwd(target_dir1[1])
|
||||
logging.info('目录2:%s' % target_dir1[2])
|
||||
self.ftp.cwd(target_dir1[2])
|
||||
logging.info('目录3:%s' % target_dir1[3])
|
||||
self.ftp.cwd(target_dir1[3])
|
||||
logging.info('目录4:%s' % target_dir1[4])
|
||||
self.ftp.cwd(target_dir1[4])
|
||||
logging.info('目录5:%s' % target_dir1[5])
|
||||
self.ftp.cwd(target_dir1[5])
|
||||
logging.info('目录6:%s' % target_dir1[6])
|
||||
self.ftp.cwd(target_dir1[6])
|
||||
logging.info('目录7:%s' % target_dir1[7])
|
||||
self.ftp.cwd(target_dir1[7])
|
||||
remotenames = self.ftp.nlst()
|
||||
logging.info('FTP目录文件:%s' % remotenames)
|
||||
for file in remotenames:
|
||||
@@ -48,6 +62,9 @@ class FtpController():
|
||||
return 1
|
||||
except Exception:
|
||||
return 0
|
||||
finally:
|
||||
self.ftp.quit()
|
||||
logging.info("ftp已关闭")
|
||||
|
||||
# 下载目录下的检测文件
|
||||
def download_reportfile_tree(self, target_dir, serverdir, reportpath):
|
||||
@@ -61,6 +78,8 @@ class FtpController():
|
||||
self.ftp.cwd(target_dir1[1]) # 切换工作路径
|
||||
logging.info('目录2:%s' % target_dir1[2])
|
||||
self.ftp.cwd(target_dir1[2]) # 切换工作路径
|
||||
logging.info('目录2:%s' % target_dir1[3])
|
||||
self.ftp.cwd(target_dir1[3]) # 切换工作路径
|
||||
remotenames = self.ftp.nlst()
|
||||
logging.info('FTP目录检测报告文件:%s' % remotenames)
|
||||
for filename in remotenames:
|
||||
|
||||
Reference in New Issue
Block a user