コード例 #1
0
ファイル: callftp.py プロジェクト: raapchikftp/raapchikftp
	def getFtpSession(self):
		try:
			clientsess = Clientftpsession(host=self.config['FTP_HOST'],port=self.config['FTP_PORT'],uname=self.config['FTP_USER'],upass=self.config['FTP_PASSW'],acv_pcv=self.config['FTP_ACV_PCV'])
			self.ftp_session = clientsess.getFtpSession(self.config['FTP_CON_TYPE'])
			for file_dtl in self.files_detail:
				if self.action_type == 'upld':
					file_status = self.try_upload_action(file_dtl[0][0],file_dtl[0][1])
				elif self.action_type == 'dwnld':
					file_status = self.try_download_action(file_dtl[0][0],file_dtl[0][1])
				else:
					sys.exit(1)
				self.file_status['file_status'].append((file_dtl[1],file_status))
			self.ftp_session.closeFTP()
			if self.action_type == 'dwnld':
				msg = 'Files downloaded successfully'
			else:
				msg = 'Files uploaded successfully'

			msg_sound = 'chick$'+str(self.config['FTP_PLAY_SOUND'])
			# p = Process(target=runftprocess, args=(msg,)).start()
			runftprocess((msg,))
			if str(self.config['FTP_PLAY_SOUND']) == '1':
				play_sound((msg_sound,))
				# p2 = Process(target=play_sound, args=(msg_sound,)).start()
			
			sys.exit(1)
		except FTP_ERROR as e:
			if str(self.config['FTP_PLAY_SOUND']) == '1':
				e.show_error('laugh$'+str(self.config['FTP_PLAY_SOUND']))
			sys.exit(1)
コード例 #2
0
	def __init__(self,params,ky=''):
		try:
			if params['FTP_CONN_NAME'] == '' or params['FTP_HOST'] == '' or params['FTP_PORT'] == '' or params['FTP_CON_TYPE'] == '' or params['FTP_USER'] == '' or params['FTP_PASSW'] == '' or params['FTP_WWW_REMOTE'] == '' or params['FTP_WWW_LOCAL'] == '' or params['FTP_ACV_PCV'] == '':
				raise FTP_ERROR('Oops: Please dont leave any config parameter blank')
				
			import os,ntpath
			if os.path.splitext(ntpath.basename(params['FTP_WWW_REMOTE']))[-1] != '':
				raise FTP_ERROR('Please enter valid remote path')
				
			from clientftpsession import Clientftpsession
			clientsess = Clientftpsession(host=params['FTP_HOST'],port=params['FTP_PORT'],uname=params['FTP_USER'],upass=params['FTP_PASSW'],acv_pcv=params['FTP_ACV_PCV'])
			self.ftp_session = clientsess.getFtpSession(params['FTP_CON_TYPE'])
			# print "Dir listing RM"
			self.ftp_session.listDirFTP(params['FTP_WWW_REMOTE'])
			self.ftp_session.closeFTP()

			self.db = CONN_ZDB(DBPATH)
			self.dbroot = self.db.dbroot
			if ky != '':
				local_ftp_key = r''+ky
				edit_ky = self.dbroot[local_ftp_key]
			# else:
				# local_ftp_key = r''+params['FTP_KEY']
			edit_ky = params

			# self.dbroot[local_ftp_key] = edit_ky
			self.db.commit(edit_ky)
			self.db.close()
			if ky == '':
				args = ["notify.exe", ('FTP config added successfully',)]
			else:
				args = ["notify.exe", ('FTP config updated successfully',)]
			
			subprocess.Popen(args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, close_fds=True)
			args = ["play_sound.exe", ('chick$'+str(params['FTP_PLAY_SOUND']),)]
			if str(params['FTP_PLAY_SOUND']) == '1':
				subprocess.Popen(args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, close_fds=True)

			sys.exit(1)
		except FTP_ERROR as e:
			args = ["play_sound.exe", ('laugh$'+str(params['FTP_PLAY_SOUND']),)]
			root = Tkinter.Tk()
			root.withdraw()
			if str(params['FTP_PLAY_SOUND']) == '1':
				subprocess.Popen(args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, close_fds=True)
			tkMessageBox.showerror('FTP ERROR',e.msg,parent=root)
			root.destroy()
コード例 #3
0
	def get_all_files(self):
		manip_file_path = self.filemanip.trim_ftp_path(self.current_path)
		rmt_dir = self.filemanip.convert_filepath_ftp_path(self.current_path,manip_file_path)
		try:
			clientsess = Clientftpsession(host=self.config['FTP_HOST'],port=self.config['FTP_PORT'],uname=self.config['FTP_USER'],upass=self.config['FTP_PASSW'],acv_pcv=self.config['FTP_ACV_PCV'])
			self.ftp_session = clientsess.getFtpSession(self.config['FTP_CON_TYPE'])
			rmt_files = self.ftp_session.listDirFTP(rmt_dir[1])
			self.ftp_session.closeFTP()
			path_sepr = '/' if os.path.splitdrive(manip_file_path)[0] == '' else '\\'
				
			local_path_sepr = '\\' if os.path.splitdrive(self.current_path)[0] != '' else '/'
			rmt_files = [self.filemanip.convert_filepath_ftp_path(self.current_path + local_path_sepr + x , manip_file_path + path_sepr + x) for x in rmt_files]
			rmt_files = [(x[1].replace('//','/'),x[0]) for x in rmt_files]
			return rmt_files
		except FTP_ERROR as e:
			if str(self.config['FTP_PLAY_SOUND']) == '1':
				e.show_error('laugh$'+str(self.config['FTP_PLAY_SOUND']))
			sys.exit(1)