Exemplo n.º 1
0
 def _download_to(self, url, filename):
     self.info("Downloading %s", url)
     # Download the file
     fp, info = None, None
     try:
         checker = HashChecker.from_url(url)
         fp = self.open_url(strip_fragment(url))
         if isinstance(fp, urllib.error.HTTPError):
             raise DistutilsError(
                 "Can't download %s: %s %s" % (url, fp.code, fp.msg)
             )
         headers = fp.info()
         blocknum = 0
         bs = self.dl_blocksize
         size = -1
         if "content-length" in headers:
             # Some servers return multiple Content-Length headers :(
             sizes = get_all_headers(headers, 'Content-Length')
             size = max(map(int, sizes))
             self.reporthook(url, filename, blocknum, bs, size)
         with open(filename, 'wb') as tfp:
             while True:
                 block = fp.read(bs)
                 if block:
                     checker.feed(block)
                     tfp.write(block)
                     blocknum += 1
                     self.reporthook(url, filename, blocknum, bs, size)
                 else:
                     break
             self.check_hash(checker, filename, tfp)
         return headers
     finally:
         if fp:
             fp.close()
Exemplo n.º 2
0
 def _download_to(self, url, filename):
     self.info("Downloading %s", url)
     # Download the file
     fp, info = None, None
     try:
         checker = HashChecker.from_url(url)
         fp = self.open_url(strip_fragment(url))
         if isinstance(fp, urllib.error.HTTPError):
             raise DistutilsError("Can't download %s: %s %s" %
                                  (url, fp.code, fp.msg))
         headers = fp.info()
         blocknum = 0
         bs = self.dl_blocksize
         size = -1
         if "content-length" in headers:
             # Some servers return multiple Content-Length headers :(
             sizes = get_all_headers(headers, 'Content-Length')
             size = max(map(int, sizes))
             self.reporthook(url, filename, blocknum, bs, size)
         with open(filename, 'wb') as tfp:
             while True:
                 block = fp.read(bs)
                 if block:
                     checker.feed(block)
                     tfp.write(block)
                     blocknum += 1
                     self.reporthook(url, filename, blocknum, bs, size)
                 else:
                     break
             self.check_hash(checker, filename, tfp)
         return headers
     finally:
         if fp:
             fp.close()
Exemplo n.º 3
0
            )
        else:
            raise DistutilsError(
                "Can't process plain .py files without an '#egg=name-version'"
                " suffix to enable automatic setup script generation."
            )

    dl_blocksize = 8192
    def _download_to(self, url, filename):
        self.info("Downloading %s", url)
        # Download the file
<<<<<<< HEAD
        fp, tfp, info = None, None, None
        try:
            checker = HashChecker.from_url(url)
            fp = self.open_url(strip_fragment(url))
            if isinstance(fp, HTTPError):
=======
        fp, info = None, None
        try:
            checker = HashChecker.from_url(url)
            fp = self.open_url(strip_fragment(url))
            if isinstance(fp, urllib.error.HTTPError):
>>>>>>> 54eef0be98b1b67c8507db91f4cfa90b64991027
                raise DistutilsError(
                    "Can't download %s: %s %s" % (url, fp.code,fp.msg)
                )
            headers = fp.info()
            blocknum = 0
            bs = self.dl_blocksize
            size = -1
Exemplo n.º 4
0
                "Can't process plain .py files without an '#egg=name-version'"
                " suffix to enable automatic setup script generation."
            )

    dl_blocksize = 8192
    def _download_to(self, url, filename):
        self.info("Downloading %s", url)
        # Download the file
<<<<<<< HEAD
        fp, info = None, None
=======
        fp, tfp, info = None, None, None
>>>>>>> e4baf504ede925f4f1e07d823c9b20b3d0dbe14c
        try:
            checker = HashChecker.from_url(url)
            fp = self.open_url(strip_fragment(url))
            if isinstance(fp, HTTPError):
                raise DistutilsError(
                    "Can't download %s: %s %s" % (url, fp.code,fp.msg)
                )
            headers = fp.info()
            blocknum = 0
            bs = self.dl_blocksize
            size = -1
            if "content-length" in headers:
                # Some servers return multiple Content-Length headers :(
                sizes = get_all_headers(headers, 'Content-Length')
                size = max(map(int, sizes))
                self.reporthook(url, filename, blocknum, bs, size)
<<<<<<< HEAD
            with open(filename,'wb') as tfp: