Beispiel #1
0
    def run_command(self, options, args):
        headinfo = Downloader.read_head_info(PYTHONZ_UPDATE_URL)
        content_type = headinfo['content-type']
        filename = "pythonz-latest"
        distname = "%s.tgz" % filename
        download_file = os.path.join(PATH_DISTS, distname)
        # Remove old tarball
        unlink(download_file)
        logger.info("Downloading %s as %s" % (distname, download_file))
        try:
            Downloader.fetch(PYTHONZ_UPDATE_URL, download_file)
        except DownloadError:
            unlink(download_file)
            logger.error("Failed to download. `%s`" % PYTHONZ_UPDATE_URL)
            sys.exit(1)
        except:
            unlink(download_file)
            raise

        extract_dir = os.path.join(PATH_BUILD, filename)
        rm_r(extract_dir)
        extract_downloadfile(content_type, download_file, extract_dir)

        try:
            logger.info("Installing %s into %s" % (extract_dir, ROOT))
            s = Subprocess()
            s.check_call([
                sys.executable,
                os.path.join(extract_dir, 'pythonz_install.py'), '--upgrade'
            ])
        except:
            logger.error("Failed to update pythonz.")
            sys.exit(1)
        logger.info("pythonz has been updated.")
Beispiel #2
0
    def run_command(self, options, args):
        headinfo = Downloader.read_head_info(PYTHONZ_UPDATE_URL)
        content_type = headinfo["content-type"]
        filename = "pythonz-latest"
        distname = "%s.tgz" % filename
        download_file = os.path.join(PATH_DISTS, distname)
        # Remove old tarball
        unlink(download_file)
        logger.info("Downloading %s as %s" % (distname, download_file))
        try:
            Downloader.fetch(PYTHONZ_UPDATE_URL, download_file)
        except DownloadError:
            unlink(download_file)
            logger.error("Failed to download. `%s`" % PYTHONZ_UPDATE_URL)
            sys.exit(1)
        except:
            unlink(download_file)
            raise

        extract_dir = os.path.join(PATH_BUILD, filename)
        rm_r(extract_dir)
        if not extract_downloadfile(content_type, download_file, extract_dir):
            sys.exit(1)

        try:
            logger.info("Installing %s into %s" % (extract_dir, ROOT))
            s = Subprocess()
            s.check_call([sys.executable, os.path.join(extract_dir, "pythonz_install.py"), "--upgrade"])
        except:
            logger.error("Failed to update pythonz.")
            sys.exit(1)
        logger.info("pythonz has been updated.")
Beispiel #3
0
 def _update_pythonz(self, options, args):
     download_url = PYTHONZ_UPDATE_URL
     headinfo = get_headerinfo_from_url(download_url)
     content_type = headinfo['content-type']
     filename = "pythonz-latest"
     distname = "%s.tgz" % filename
     download_file = os.path.join(PATH_DISTS, distname)
     # Remove old tarball
     unlink(download_file)
     try:
         d = Downloader()
         d.download(distname, download_url, download_file)
     except:
         logger.error("Failed to download. `%s`" % download_url)
         sys.exit(1)
     
     extract_dir = os.path.join(PATH_BUILD, filename)
     rm_r(extract_dir)
     if not extract_downloadfile(content_type, download_file, extract_dir):
         sys.exit(1)
     
     try:
         logger.info("Installing %s into %s" % (extract_dir, ROOT))
         s = Subprocess()
         s.check_call([sys.executable, os.path.join(extract_dir,'pythonz_install.py'), '--upgrade'])
     except:
         logger.error("Failed to update pythonz.")
         sys.exit(1)
     logger.info("The pythonz has been updated.")
Beispiel #4
0
 def download_and_extract(self):
     if is_file(self.download_url):
         path = fileurl_to_path(self.download_url)
         if os.path.isdir(path):
             logger.info('Copying %s into %s' % (path, self.build_dir))
             shutil.copytree(path, self.build_dir)
             return
     if os.path.isfile(self.download_file):
         logger.info("Use the previously fetched %s" % (self.download_file))
     else:
         base_url = Link(self.download_url).base_url
         try:
             dl = Downloader()
             dl.download(base_url, self.download_url, self.download_file)
         except:
             unlink(self.download_file)
             logger.error("Failed to download.\n%s" % (sys.exc_info()[1]))
             sys.exit(1)
     # extracting
     if not extract_downloadfile(self.content_type, self.download_file, self.build_dir):
         sys.exit(1)
Beispiel #5
0
 def download_and_extract(self):
     self.download()
     if not extract_downloadfile(self.content_type, self.download_file, self.build_dir):
         sys.exit(1)
Beispiel #6
0
 def download_and_extract(self):
     self.download()
     if not extract_downloadfile(self.content_type, self.download_file,
                                 self.build_dir):
         sys.exit(1)
Beispiel #7
0
 def download_and_extract(self):
     self.download()
     extract_downloadfile(self.content_type, self.download_file, self.build_dir)