本文整理汇总了Python中ftplib.FTP_TLS.getwelcome方法的典型用法代码示例。如果您正苦于以下问题:Python FTP_TLS.getwelcome方法的具体用法?Python FTP_TLS.getwelcome怎么用?Python FTP_TLS.getwelcome使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ftplib.FTP_TLS
的用法示例。
在下文中一共展示了FTP_TLS.getwelcome方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connexionftp
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import getwelcome [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()
示例2: connect
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import getwelcome [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
示例3: connect
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import getwelcome [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());
示例4: __init__
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import getwelcome [as 别名]
class FTPS:
def __init__(self):
self.ftps = FTP_TLS( )
def connect(self):
self.ftps.connect('192.168.0.102', 2121)
print(self.ftps.getwelcome())
def login(self):
self.ftps.login('anderson', 'nosredna89')
self.ftps.prot_p() #para fazer a conexação de dados segura
def close(self):
self.ftps.close()
示例5: ftp_backup
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import getwelcome [as 别名]
def ftp_backup(dmpdir,dbname):
try:
#
ftp =FTP_TLS()
ftp.connect(ftphost,ftpport)
ftp.login(ftpuser,ftppass)
ftp.prot_p()
print "Welcome:",ftp.getwelcome()
print ftp.retrlines('LIST')
# ftp =FTP()
# ftp.connect(ftphost,ftpport)
# ftp.login(ftpuser,ftppass)
# print "Welcome:",ftp.getwelcome()
# print ftp.retrlines('LIST')
except Exception,e:
print e
return
示例6: Sftpimpl
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import getwelcome [as 别名]
class Sftpimpl(Ftpimpl):
def __init__(self):
self.log = ProcessLogger()
def connectFTP(self,host='',port='',uname='',upass='',ssh_host_key='',acv_pcv=''):
if host=='' or port=='' or uname=='' or upass=='':
raise FTP_ERROR('Oops: Blank config parameters, Please dont leave any config parameter blank')
self.host = host
log_id = self.log.processlog(logid=0,f1=False,f2=False,hostnm=host,up_dw='login',typ='new',status='Pending',result='trying to connect...')
hostStr = '%s:%s' %(host,port)
usrHostStr = '%[email protected]%s' %(uname,hostStr)
try:
self.ftp = FTP_TLS(hostStr)
if acv_pcv == 'Active':
self.ftp.set_pasv(False)
elif acv_pcv == 'Passive':
self.ftp.set_pasv(True)
self.ftp.login(uname,upass)
self.ftp.prot_p()
return_msg = self.ftp.getwelcome()
self.log.processlog(logid=log_id,f1=False,f2=False,hostnm=host,up_dw='login',typ='edit',status='Done',result=return_msg)
except Exception as e:
self.log.processlog(logid=log_id,f1=False,f2=False,hostnm=host,up_dw='login',typ='edit',status='Failed',result=str(e))
raise FTP_ERROR('Connection error: Reasons \n\n(Internet connection)\n(Remote server down)\n(Config settings) ')
示例7: FTP_TLS
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import getwelcome [as 别名]
import ftplib
import glob
import os
import time
import requests
from ftplib import FTP_TLS
host = "quandl.brickftp.com"
ftps = FTP_TLS(host)
ftps.prot_p()
print (ftps.getwelcome())
try:
print ("Logging in...")
ftps.login("tricolor", "9v0$NkRUaM")
file_header = "=\nnotify: [email protected]\ntoken: 9kzPsYLWsnmrZ1xTENrX\n=\n"
headers = {"x-amz-acl": "bucket-owner-full-control"}
for input_file in glob.iglob("*.csv"):
with file(input_file, 'r') as original:
data = original.read()
if file_header not in data:
with file(input_file, 'w') as modified:
modified.write(file_header + data)
file_name = input_file
print "Opening file:" + file_name
fp = open (file_name,'rb')
ftps.storbinary('STOR ' + file_name, fp)
fp.close()