当前位置: 首页>>代码示例>>Python>>正文


Python FTP_TLS.prot_p方法代码示例

本文整理汇总了Python中ftplib.FTP_TLS.prot_p方法的典型用法代码示例。如果您正苦于以下问题:Python FTP_TLS.prot_p方法的具体用法?Python FTP_TLS.prot_p怎么用?Python FTP_TLS.prot_p使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ftplib.FTP_TLS的用法示例。


在下文中一共展示了FTP_TLS.prot_p方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connexionftp

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
def connexionftp(adresseftp, nom, mdpasse, passif):
	"""connexion au serveur ftp et ouverture de la session
	   - adresseftp: adresse du serveur ftp
	   - nom: nom de l'utilisateur enregistré ('anonymous' par défaut)
	   - mdpasse: mot de passe de l'utilisateur ('[email protected]' par défaut)
	   - passif: active ou désactive le mode passif (True par défaut)
	   retourne la variable 'ftplib.FTP' après connexion et ouverture de session
	"""
	try:
		verbose('Attente connexion FTP .....')
		if modeSSL:
			ftp = FTP_TLS()
			ftp.connect(adresseftp, 21)
			ftp.login(nom, mdpasse)
			ftp.prot_p()
			ftp.set_pasv(passif)
		else:
			ftp = (ftplib.FTP(adresseftp, nom, mdpasse))
			
		ftp.cwd(destination)
		verbose ('Destination : '+destination)
		verbose('Connexion FTP OK')
		etat = ftp.getwelcome()
		verbose("Etat : "+ etat) 
		return ftp
	except:
		verbose('Connexion FTP impossible', True)
		suppressionDossierTemp(dossierTemporaireFTP)
		sys.exit()
开发者ID:Michelgard,项目名称:backup_serveur,代码行数:31,代码来源:backupserveurFTP.py

示例2: get_session_ftps

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
 def get_session_ftps(host, login=None, password=None, port=21, auth=False, protocol=True):
     """
     Creates connection with FTPS server
     :param host: host of FTPS server
     :param login: user's name
     :param password: password for user
     :param port: port of FTPS server
     :param auth: if it is true sets up secure control
     connection by using TLS/SSL
     :param protocol: if it is true sets up secure data connection
     else sets up clear text data connection
     :return: FTPConnector
     :type host: str
     :type login: str
     :type password: str
     :type port: int
     :type auth: bool
     :type protocol: bool
     :rtype: FTPConnector
     """
     try:
         ftp = FTP_TLS()
         ftp.connect(host, port)
         ftp.login(login, password)
         if protocol:
             ftp.prot_p()
         else:
             ftp.prot_c()
         if auth:
             ftp.auth()
         return FTPConnector(ftp)
     except error_perm, exp:
         raise FTPConnectorError(
             exp.message
         )
开发者ID:epam,项目名称:Merlin,代码行数:37,代码来源:ftp.py

示例3: Push

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
def Push( FtpServer, Username, Password, uploadlist = FilesToPut, port = 21, passive = False, StartTls = False ):
	print "Login to %s:%s using %s:%s (%s%s)"%(FtpServer, port, Username, 'xxx', 
				'passive' if passive else 'active', 
				'/tls' if StartTls else '')

	if StartTls:
		ftp = FTP_TLS()
	else:
		ftp = FTP()
	
	#ftp.set_debuglevel(2)

	ftp.connect( FtpServer, port )
	ftp.login( Username, Password )                     # user anonymous, passwd [email protected]
	ftp.set_pasv( passive )

	if StartTls:
		ftp.prot_p()	    

	for f in uploadlist:
		print "uploading %s"%f		
		fp = open( f, 'rb')
		ftp.storbinary('STOR %s'%os.path.basename(f), fp)     # send the file

	ftp.quit()
开发者ID:rodsur,项目名称:ProItsScripts,代码行数:27,代码来源:PushToFtp.py

示例4: sync

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
 def sync(self):
     """
     downloads all needed_files from self.hostname (FTP)
     of the downloaded files, extracts .gz files to same local_working_dir
         -using self.extract function
     parses the .txt downloaded needed_files
         -using the self.parse function
     """
     ftps = FTP_TLS(self.hostname) # connect to host, default port
     ftps.login(self.username, self.password)
     ftps.prot_p()
     ftps.cwd(self.remote_dir) # change into "logs" directory
     ftps.retrlines('LIST *.gz *.txt', self.ftp_list_callback) # list directory contents
     for needed_file in self.needed_files:
         if self.logging:
             print "Writing {0} to {1}...".format(needed_file, self.local_working_dir)
         ftps.retrbinary("RETR " + needed_file, open(os.path.join(self.local_working_dir, needed_file), 'wb').write)
     if self.logging:
         print "done syncing files"
     for needed_file in self.needed_files:
         if needed_file.endswith(".gz"):
             self.extract(os.path.join(self.local_working_dir, needed_file))
         txt_file_name = needed_file.replace('.gz','')#if already a .txt file, this is unnceccessary but works.
         self.parse(txt_file_name)
     if self.logging:
         print "done extracting/parsing .gz files"
     ftps.quit()
开发者ID:tropo,项目名称:ftp_cdr_tool,代码行数:29,代码来源:ftp_cdr_tool.py

示例5: getfilelist

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
def getfilelist(server, port, user, password, db):
	sqliteconnection = sqlite3.connect(db)
	sqlitecursor = sqliteconnection.cursor()

	sqlitecursor.execute('''CREATE TABLE IF NOT EXISTS files (date int, name text,  CONSTRAINT 'id_UNIQUE' UNIQUE ('name'))''')
	sqliteconnection.commit()


	ftpsconnection = FTP_TLS()
	ftpsconnection.connect(server, port)
	ftpsconnection.auth()
	ftpsconnection.prot_p()
	ftpsconnection.login(user, password)
	ftpsconnection.prot_p()

	rootfiles = ftpsconnection.nlst()

	for i in range(0,5):
		episodes = ftpsconnection.nlst(rootfiles[i])

		for episode in episodes:
			sqlitecursor.execute('''INSERT OR IGNORE INTO files VALUES ("%(date)d", "%(folder)s")''' % {'date': time.time(), 'folder': ("/" + rootfiles[i] + "/" + episode) } )
			sqliteconnection.commit()

	sqliteconnection.close()
	ftpsconnection.quit()
	ftpsconnection.close()
开发者ID:sikevux,项目名称:FTPSync,代码行数:29,代码来源:Sync.py

示例6: connect

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
 def connect(self):
     #初始化 FTP 链接
     if self.ftp_ssl:
         ftp = FTPS()
     else:
         ftp = FTP()
     print('-'*20+self.ftp_name+'-'*20)
     print('connect '+('ftps' if self.ftp_ssl else 'ftp')+'://'+self.ftp_host+':'+self.ftp_port)
     try:
         ftp.connect(self.ftp_host,self.ftp_port)
     except Exception as e:
         print (e)
         print ('connect ftp server failed')
         sys.exit()
     try:
         ftp.login(self.ftp_user,self.ftp_passwd)
         print ('login ok')
     except Exception as e:#可能服务器不支持ssl,或者用户名密码不正确
         print (e)
         print ('Username or password are not correct')
         sys.exit()        
     
     if self.ftp_ssl:
         try:    
             ftp.prot_p()
         except Exception as e:
             print (e)
             print ('Make sure the SSL is on ;')
         
     print(ftp.getwelcome())
     ftp.cwd(self.ftp_webroot)
     print('current path: '+ftp.pwd())
     
     self.ftp=ftp
开发者ID:ttym7993,项目名称:sync_web,代码行数:36,代码来源:sync_web.py

示例7: sendUpdateFilesFtp

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
def sendUpdateFilesFtp():
    print "---- Send update files by FTP"
    global serverFtp
    global userFtp
    global passFtp
    
    from ftplib import FTP_TLS
    ftps = FTP_TLS(serverFtp)
    ftps.set_debuglevel(1)
    ftps.login(userFtp, passFtp)
    ftps.prot_p()
    ftps.cwd('/files/updates')
    
    ftps.storbinary('STOR ' + 'file_list.md5', open(quiterssFileRepoPath + '\\file_list.md5', 'rb'))
    ftps.storbinary('STOR ' + 'VersionNo.h', open(quiterssSourcePath + '\\src\\VersionNo.h', 'rb'))
    ftps.storbinary('STOR ' + 'HISTORY_EN', open(quiterssSourcePath + '\\HISTORY_EN', 'rb'))
    ftps.storbinary('STOR ' + 'HISTORY_RU', open(quiterssSourcePath + '\\HISTORY_RU', 'rb'))
    
    prepareFileList7z = []
    for file in prepareFileList:
        prepareFileList7z.append(file + '.7z')

    for fileName in prepareFileList7z:
        ftps.storbinary('STOR ' + 'windows' + fileName.replace('\\','/'), open(quiterssFileRepoPath + '\\windows' + fileName, 'rb'))

    ftps.quit()
开发者ID:barkinet,项目名称:quite-rss.tools,代码行数:28,代码来源:prepare-install.py

示例8: sendPackagesFtp

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
def sendPackagesFtp():
    print "---- Send packages by FTP"
    global serverFtp
    global userFtp
    global passFtp

    from ftplib import FTP_TLS
    ftps = FTP_TLS(serverFtp)
    ftps.set_debuglevel(1)
    ftps.login(userFtp, passFtp)
    ftps.prot_p()
    try:
        ftps.sendcmd('MKD ' + '/files/' + strProductVer)
    except Exception:
        print 'Directory already exists'
    ftps.cwd('/files/' + strProductVer)
    
    filesListFtp = ftps.nlst()
    filesList = os.listdir(packagesPath)
    newFilesList = [e for e in filesList if not(e in filesListFtp)]
    
    for fileName in newFilesList:
        ftps.storbinary('STOR ' + fileName, open(packagesPath + '\\' + fileName, 'rb'))

    ftps.quit()
开发者ID:barkinet,项目名称:quite-rss.tools,代码行数:27,代码来源:prepare-install.py

示例9: write_file

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
 def write_file(self):
   output = open('chan_output.htm', 'w')
   for channel in self.main.channels:
     self.logger.log(LOG_DEBUG, "Writing output for %s, topic %s" % (channel, self.topics[channel]))
     output.write("<b>Channel:</b> %s\n<br /><b>Topic:</b> %s\n<br /><b>Users:</b>\n<ul>\n" % (channel, self.topics[channel]))
     for user in self.main.channels[channel]['users']:
       output.write("  <li>%s</li>\n" %(user))
     output.write("</ul>\n\n")
   output.close
   
   output = open('chan_output.htm', 'r')
   self.update_all = 0
   ftp_server = 'whub25.webhostinghub.com'
   ftp_user = '[email protected]'
   passfile = open('password.txt','r')
   password = passfile.readline()
   passfile.close()
   password = password.rstrip('\n')
   self.logger.log(LOG_INFO, "Connecting to FTP server %s, username %s" % (ftp_server, ftp_user))
   ftp = FTP_TLS(ftp_server, ftp_user, password)
   ftp.prot_p()
   self.logger.log(LOG_INFO, "Successfully logged in, storing file")
   ftp.storlines('STOR chan_output.htm', output)
   ftp.close()
   output.close()
   self.update_all = 0
   self.logger.log(LOG_INFO, "Done")
开发者ID:tntexplosivesltd,项目名称:modbot_plugins,代码行数:29,代码来源:live_stats.py

示例10: storeFtplib

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
def storeFtplib(dataframe, filename="cameliaBalAGKevin.csv", compression = None, toPrint = False):
    """
    function that connects to the remote FTP serveur and upload a pandas dataframe
    the upload file must be a pandasDataframe and will be written in a csv file.
    It can be uploaded as a bz2, gz encoded or not encoded at all
    if it is encoded, the right extension must be present in the name
    -- IN
    dataframe : the dataframe to upload (pandas.Dataframe)
    filename : the filename with its extension to be downloaded from the remote ftp server (string)
    compression : string that specifies the encoding of the file (string in [None,"gz","bz2"] default: None
    toPrint : boolean that settles if the function should print its progress and results (boolean) default: False
    -- OUT
    flag : boolean that settles if everything was successful (True: no problem, False: an error occured)
    """
    startTime = time.time()
    if toPrint:
        print ""
        print ""
        print "==========================================="
        print "=== Connection to the remote FTP server ==="
        print "==========================================="
        print ""
        print "using ftplib"
        print "loading :",filename
        print "" 
    ftp = FTP_TLS()
    # retrieving information about account on ftp server
    (user, password, host, port) = getAccount()
    if user==None:
        print "error : coudn't read the account information"
        return False
    # connecting and logging in
    try:
        ftp.connect(host,port)
        ftp.login(user,password)
    except:
        print "error : unable to connect to the ftp server"
        return False
    # establishing the security protocol
    ftp.prot_p()
    if toPrint:
        print "connected to the FTP server"
    try:
        lines = dataframe.to_csv(path_or_buff = None,sep="\t",columns=dataframe.columns)
    except:
        print "error : impossible to convert the dataframe into csv lines"
        return False
    sio = StringIO.StringIO(lines)
    ftp.storlines(cmd="STOR "+filename, fp=sio)
#     try:
#         ftp.storlines(cmd="STOR "+filename, file=lines)
#     except:
#         print "error : impossible to upload the file"
#         return False
    interval = time.time() - startTime 
    if toPrint:
        print 'Dataframe uploaded :', interval, 'sec'
    return True
    
开发者ID:KevinBienvenu,项目名称:RiskAnalyticsPerso,代码行数:60,代码来源:FTPTools.py

示例11: connect

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
 def connect(self):
     self.sock = socket.create_connection((self.ftp_server, self.port), self.timeout)
     self.af = self.sock.family
     self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile,ssl_version=ssl.PROTOCOL_TLSv1)
     self.file = self.sock.makefile('rb')
     self.welcome = self.getresp()
     self.login(self.username,self.password)
     FTP_TLS.prot_p(self)
     return self.welcome
开发者ID:abigbigbird,项目名称:Sirius,代码行数:11,代码来源:ftp_operator.py

示例12: connect

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
    def connect(self):
        ftps = FTP_TLS(self.host)
        ftps.login(self.username, self.passwd)

        # switch to secure data connection..
        # IMPORTANT!
        # Otherwise, only the user and password is encrypted and not all the file data.
        ftps.prot_p()
        return ftps
开发者ID:dustinbrown,项目名称:mediagrabber,代码行数:11,代码来源:ftps.py

示例13: connect

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
def connect():
    global ftp;
    if remoteTLS:
        context = ssl.create_default_context();
        ftp = FTP_TLS(remoteHost, remoteUser, remotePassword, acct="", keyfile=None, certfile=None, context=context, timeout=20);
        ftp.prot_p();
    else:
        ftp = FTP(remoteHost, remoteUser, remotePassword, 20);
    print(ftp.getwelcome());
开发者ID:j-benson,项目名称:Deploy,代码行数:11,代码来源:deploy.py

示例14: start

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
	def start(self):
		# create connection
		for ftpserver, users in self.db.iteritems():
			for s_user in users:
				self.log.log("Connecting to %s: user: %s pass: %s" % (ftpserver, s_user.user, s_user.passwd))
				ftp = FTP_TLS(ftpserver)     # connect to host, default port
				ftp.login(user=s_user.user, passwd=s_user.passwd) 
				ftp.prot_p()          # switch to secure data connection
				ftp.retrlines('LIST', self.parseFiles)
				self.log.log("Done! now quit...")
				ftp.quit()
开发者ID:yotam-gafni,项目名称:supertrends,代码行数:13,代码来源:FTPCrawler.py

示例15: ftpUpload

# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import prot_p [as 别名]
def ftpUpload(filename):
    from ftplib import FTP_TLS
    import os
    
    ftps = FTP_TLS()
    ftps.connect('pwcrack.init6.me', '21')
    ftps.auth()
    ftps.login('DC214', 'passwordcrackingcontest')
    ftps.prot_p()
    ftps.set_pasv(True)
    local_file = open(filename, 'rb')
    ftps.storbinary('STOR '+filename, local_file)
开发者ID:initiate6,项目名称:pwcrack,代码行数:14,代码来源:FTPupload.py


注:本文中的ftplib.FTP_TLS.prot_p方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。