(self, pyfile)
| 29 | self.resume_download = True |
| 30 | |
| 31 | def process(self, pyfile): |
| 32 | p_url = urlparse.urlparse(pyfile.url) |
| 33 | netloc = p_url.netloc |
| 34 | |
| 35 | pyfile.name = parse_name(p_url.path.rpartition('/')[2]) |
| 36 | |
| 37 | if not "@" in netloc: |
| 38 | #@TODO: Recheck in 0.4.10 |
| 39 | if self.account: |
| 40 | servers = [x['login'] for x in self.account.getAllAccounts()] |
| 41 | else: |
| 42 | servers = [] |
| 43 | |
| 44 | if netloc in servers: |
| 45 | self.log_debug("Logging on to %s" % netloc) |
| 46 | self.req.addAuth(self.account.get_login('password')) |
| 47 | |
| 48 | else: |
| 49 | pwd = self.get_password() |
| 50 | if ':' in pwd: |
| 51 | self.log_debug("Logging on to %s" % netloc) |
| 52 | self.req.addAuth(pwd) |
| 53 | else: |
| 54 | self.log_debug("Using anonymous logon") |
| 55 | |
| 56 | try: |
| 57 | headers = self.load(pyfile.url, just_header=True) |
| 58 | |
| 59 | except pycurl.error, e: |
| 60 | if "530" in e.args[1]: |
| 61 | self.fail(_("Authorization required")) |
| 62 | else: |
| 63 | self.fail(_("Error %d: %s") % e.args) |
| 64 | |
| 65 | self.req.http.c.setopt(pycurl.NOBODY, 0) |
| 66 | self.log_debug(self.req.http.header) |
| 67 | |
| 68 | if "content-length" in headers: |
| 69 | pyfile.size = headers.get("content-length") |
| 70 | self.download(pyfile.url) |
| 71 | |
| 72 | else: |
| 73 | #: Naive ftp directory listing |
| 74 | if re.search(r'^25\d.*?"', self.req.http.header, re.M): |
| 75 | pyfile.url = pyfile.url.rstrip('/') |
| 76 | pkgname = "/".join([pyfile.package().name, |
| 77 | urlparse.urlparse(pyfile.url).path.rpartition('/')[2]]) |
| 78 | |
| 79 | pyfile.url += '/' |
| 80 | |
| 81 | self.req.http.c.setopt(48, 1) #: CURLOPT_DIRLISTONLY |
| 82 | res = self.load(pyfile.url, decode=False) |
| 83 | |
| 84 | links = [pyfile.url + x for x in res.splitlines()] |
| 85 | self.log_debug("LINKS", links) |
| 86 | |
| 87 | self.pyload.api.addPackage(pkgname, links) |
| 88 |
nothing calls this directly
no test coverage detected