Entropy/FtpInterface:
- improve FTP uri parser, move to entropyTools - fix issues when no directory path is specified git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@2514 cd1c1023-2f26-0410-ae45-c471fc1f0318
This commit is contained in:
+1
-30
@@ -7935,36 +7935,7 @@ class FtpInterface:
|
||||
self.ftpuri = ftpuri
|
||||
self.ftphost = self.entropyTools.extractFTPHostFromUri(self.ftpuri)
|
||||
|
||||
self.ftpuser = ftpuri.split("ftp://")[-1].split(":")[0]
|
||||
if (self.ftpuser == ""):
|
||||
self.ftpuser = "anonymous@"
|
||||
self.ftppassword = "anonymous"
|
||||
else:
|
||||
self.ftppassword = ftpuri.split("@")[:-1]
|
||||
if len(self.ftppassword) > 1:
|
||||
self.ftppassword = '@'.join(self.ftppassword)
|
||||
self.ftppassword = self.ftppassword.split(":")[-1]
|
||||
if (self.ftppassword == ""):
|
||||
self.ftppassword = "anonymous"
|
||||
else:
|
||||
self.ftppassword = self.ftppassword[0]
|
||||
self.ftppassword = self.ftppassword.split(":")[-1]
|
||||
if (self.ftppassword == ""):
|
||||
self.ftppassword = "anonymous"
|
||||
|
||||
self.ftpport = ftpuri.split(":")[-1]
|
||||
try:
|
||||
self.ftpport = int(self.ftpport)
|
||||
except ValueError:
|
||||
self.ftpport = 21
|
||||
|
||||
self.ftpdir = ftpuri.split("ftp://")[-1]
|
||||
self.ftpdir = self.ftpdir.split("/")[-1]
|
||||
self.ftpdir = self.ftpdir.split(":")[0]
|
||||
if self.ftpdir.endswith("/"):
|
||||
self.ftpdir = self.ftpdir[:len(self.ftpdir)-1]
|
||||
if not self.ftpdir:
|
||||
self.ftpdir = "/"
|
||||
self.ftpuser, self.ftppassword, self.ftpport, self.ftpdir = self.entropyTools.extract_ftp_data(ftpuri)
|
||||
|
||||
count = 10
|
||||
while 1:
|
||||
|
||||
@@ -1702,6 +1702,41 @@ def hideFTPpassword(uri):
|
||||
newuri = uri.replace(ftppassword,"xxxxxxxx")
|
||||
return newuri
|
||||
|
||||
def extract_ftp_data(ftpuri):
|
||||
ftpuser = ftpuri.split("ftp://")[-1].split(":")[0]
|
||||
if (ftpuser == ""):
|
||||
ftpuser = "anonymous@"
|
||||
ftppassword = "anonymous"
|
||||
else:
|
||||
ftppassword = ftpuri.split("@")[:-1]
|
||||
if len(ftppassword) > 1:
|
||||
ftppassword = '@'.join(ftppassword)
|
||||
ftppassword = ftppassword.split(":")[-1]
|
||||
if (ftppassword == ""):
|
||||
ftppassword = "anonymous"
|
||||
else:
|
||||
ftppassword = ftppassword[0]
|
||||
ftppassword = ftppassword.split(":")[-1]
|
||||
if (ftppassword == ""):
|
||||
ftppassword = "anonymous"
|
||||
|
||||
ftpport = ftpuri.split(":")[-1]
|
||||
try:
|
||||
ftpport = int(ftpport)
|
||||
except ValueError:
|
||||
ftpport = 21
|
||||
|
||||
ftpdir = '/'
|
||||
if ftpuri.count("/") > 2:
|
||||
ftpdir = ftpuri.split("ftp://")[-1]
|
||||
ftpdir = ftpdir.split("/")[-1]
|
||||
ftpdir = ftpdir.split(":")[0]
|
||||
if ftpdir.endswith("/"):
|
||||
ftpdir = ftpdir[:len(ftpdir)-1]
|
||||
if not ftpdir: ftpdir = "/"
|
||||
|
||||
return ftpuser, ftppassword, ftpport, ftpdir
|
||||
|
||||
def getFileUnixMtime(path):
|
||||
return os.path.getmtime(path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user