From f9fc367427e30b7a3ca2ccad6144cb76b21f0257 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 21 Sep 2015 14:36:22 +0200 Subject: Spare code cosmetics --- module/plugins/hoster/Ftp.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'module/plugins/hoster/Ftp.py') diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 25eb44604..c9f5fa6b6 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -35,6 +35,7 @@ class Ftp(Hoster): pyfile.name = parsed_url.path.rpartition('/')[2] try: pyfile.name = urllib.unquote(str(pyfile.name)).decode('utf8') + except Exception: pass @@ -63,16 +64,22 @@ class Ftp(Hoster): if m: pyfile.size = int(m.group(1)) self.download(pyfile.url) + else: #: Naive ftp directory listing if re.search(r'^25\d.*?"', self.req.http.header, re.M): pyfile.url = pyfile.url.rstrip('/') pkgname = "/".join([pyfile.package().name, urlparse.urlparse(pyfile.url).path.rpartition('/')[2]]) + pyfile.url += '/' + self.req.http.c.setopt(48, 1) #: CURLOPT_DIRLISTONLY res = self.load(pyfile.url, decode=False) + links = [pyfile.url + x for x in res.splitlines()] self.log_debug("LINKS", links) + self.pyload.api.addPackage(pkgname, links) + else: self.fail(_("Unexpected server response")) -- cgit v1.2.3 From 3353ea228835ffa96cc73d5b5e23f6d92ba84203 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 29 Sep 2015 22:43:17 +0200 Subject: Update hoster plugins --- module/plugins/hoster/Ftp.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'module/plugins/hoster/Ftp.py') diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index c9f5fa6b6..2fa5c1aa8 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -11,7 +11,7 @@ from module.plugins.internal.Hoster import Hoster class Ftp(Hoster): __name__ = "Ftp" __type__ = "hoster" - __version__ = "0.54" + __version__ = "0.55" __status__ = "testing" __pattern__ = r'(?:ftps?|sftp)://([\w.-]+(:[\w.-]+)?@)?[\w.-]+(:\d+)?/.+' @@ -29,10 +29,10 @@ class Ftp(Hoster): def process(self, pyfile): - parsed_url = urlparse.urlparse(pyfile.url) - netloc = parsed_url.netloc + p_url = urlparse.urlparse(pyfile.url) + netloc = p_url.netloc - pyfile.name = parsed_url.path.rpartition('/')[2] + pyfile.name = p_url.path.rpartition('/')[2] try: pyfile.name = urllib.unquote(str(pyfile.name)).decode('utf8') @@ -40,20 +40,30 @@ class Ftp(Hoster): pass if not "@" in netloc: - servers = [x['login'] for x in self.account.getAllAccounts()] if self.account else [] + self.log_debug("Auth required") + + #@TODO: Recheck in 0.4.10 + if self.account: + servers = [x['login'] for x in self.account.getAllAccounts()] + else: + servers = [] if netloc in servers: self.log_debug("Logging on to %s" % netloc) - self.req.addAuth(self.account.get_info(netloc)['login']['password']) + self.req.addAuth(self.account.get_login('password')) + else: pwd = self.get_password() if ':' in pwd: self.req.addAuth(pwd) + else: + self.fail(_("Authorization required")) self.req.http.c.setopt(pycurl.NOBODY, 1) try: res = self.load(pyfile.url) + except pycurl.error, e: self.fail(_("Error %d: %s") % e.args) -- cgit v1.2.3 From 25d5726d4953b93a2e286fd6af8d4ead20670ba6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 1 Oct 2015 04:55:17 +0200 Subject: A lot of plugin code cosmetics --- module/plugins/hoster/Ftp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/Ftp.py') diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py index 2fa5c1aa8..2ff1755f4 100644 --- a/module/plugins/hoster/Ftp.py +++ b/module/plugins/hoster/Ftp.py @@ -71,7 +71,7 @@ class Ftp(Hoster): self.log_debug(self.req.http.header) m = re.search(r"Content-Length:\s*(\d+)", res) - if m: + if m is not None: pyfile.size = int(m.group(1)) self.download(pyfile.url) -- cgit v1.2.3