本文整理汇总了Python中ftplib.FTP_TLS.auth方法的典型用法代码示例。如果您正苦于以下问题:Python FTP_TLS.auth方法的具体用法?Python FTP_TLS.auth怎么用?Python FTP_TLS.auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ftplib.FTP_TLS
的用法示例。
在下文中一共展示了FTP_TLS.auth方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getfilelist
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [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()
示例2: get_session_ftps
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [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
)
示例3: ftpUpload
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [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)
示例4: ftpDownload
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [as 别名]
def ftpDownload(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_filename = filename
with open(local_filename, 'wb') as f:
def callback(data):
f.write(data)
ftps.retrbinary('RETR %s' % filename, callback)
示例5: Push
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [as 别名]
def Push( FtpServer, Username, Password, uploadlist = FilesToPut, port = 21):
print >> sys.stderr, "Login to %s:%s using %s:%s"%(FtpServer, port, Username, 'xxx')
ftp = FTP()
ftps = FTP_TLS()
ftps.connect(FtpServer,Port)
ftps.auth()
ftps.login(Username, Password) # login anonymously before securing control channel
ftps.prot_p()
ftp.set_pasv(False)
for f in uploadlist:
#print "uploading %s"%f
fp = open( f, 'rb')
os.path.basename(f)
print f
ftp.storbinary("STOR,%sx " %(os.path.basename(f),fp))
#ftp.storbinary('STOR, %s',fp %(basename(f)) ) # send the file
ftp.quit()
示例6: getfiles
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [as 别名]
def getfiles(server, port, user, password, db):
sqliteconnection = sqlite3.connect(db)
sqlitecursor = sqliteconnection.cursor()
sqlitecursor.execute('''CREATE TABLE IF NOT EXISTS latest (date int, CONSTRAINT 'id_UNIQUE' UNIQUE ('date'))''')
sqliteconnection.commit()
sqlitecursor.execute('''SELECT date FROM files WHERE date = (SELECT MAX(date) FROM files) LIMIT 1''')
latestfile = sqlitecursor.fetchone()
sqlitecursor.execute('''SELECT date FROM latest WHERE date = (SELECT MAX(date) FROM latest) LIMIT 1''')
latestfetch = sqlitecursor.fetchone()
if latestfetch is None:
latestfetch = 0
if latestfetch < latestfile:
ftpsconnection = FTP_TLS()
ftpsconnection.connect(server, port)
ftpsconnection.auth()
ftpsconnection.prot_p()
ftpsconnection.login(user, password)
ftpsconnection.prot_p()
sqlitecursor.execute('''SELECT name FROM files WHERE date > %d''' % latestfetch)
filestofetch = sqlitecursor.fetchall()
for currfile in filestofetch:
ftpsconnection.cwd(currfile[0])
filenames = ftpsconnection.nlst()
for filename in filenames:
print 'Now saving /mnt/folder' + currfile[0] + '/' + filename
localfile = open('/mnt/folder' + currfile + '/' + filename, 'wb')
ftpsconnection.retrbinary('RETR ' + filename, localfile.write)
localfile.close()
sqliteconnection.execute('''INSERT OR IGNORE INTO latest VALUES (%d)''' % time.time())
sqliteconnection.commit()
sqliteconnection.close()
ftpsconnection.quit()
ftpsconnection.close()
示例7: ftpUpload
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [as 别名]
def ftpUpload(filename, system):
from ftplib import FTP_TLS
import os
if os.path.isfile(filename):
zipFilename = compressit(filename, system)
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(zipFilename, 'rb')
ftps.storbinary('STOR '+zipFilename, local_file)
print "file %s has been uploaded." % zipFilename
return True
示例8: make_msg
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [as 别名]
def make_msg(self, args):
# make connection
conn = None
if args.ssl or args.starttls:
conn = FTP_TLS()
conn.ssl_version = PROTOCOL_TLSv1
else:
conn = FTP()
if args.verbose:
conn.set_debuglevel(1)
conn.connect(args.host, args.port, args.timeout)
if args.starttls:
conn.auth()
conn.prot_p()
conn.login(args.user, args.password)
self.conn = conn
return args.message
示例9: ftpDownload
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [as 别名]
def ftpDownload(filename, system):
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_filename = filename
with open(local_filename, 'wb') as f:
def callback(data):
print "Downloading %s ..." % filename
f.write(data)
ftps.retrbinary('RETR %s' % filename, callback)
f.close()
file_extension = str(filename.rsplit('.')[2])
if file_extension == '7z':
status = decompressit(local_filename, system)
if status:
print "file %s has been downloaded." % local_filename
示例10: int
# 需要导入模块: from ftplib import FTP_TLS [as 别名]
# 或者: from ftplib.FTP_TLS import auth [as 别名]
createEmptyDirectory = True
if opt == "-l":
detectLink = True
if ':' in args[0]:
host, port = args[0].split(':')
else:
host, port = args[0], "21"
#convert port as int
port = int(port)
if enableSSL:
if port == 21:
client = FTP_TLS(host)
client.auth()
client.prot_p()
else:
client = FTP_TLS_EXPLICIT()
client.connect(host, port)
client.prot_p()
else:
client = FTP()
print client.connect(host, int(port))
print client.login(username, password)
#log
client.login(username, password)
Dumper(client, createEmptyDirectory, filter, detectLink).do(targetDir)
client.quit()