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.")
def install(self): # cleanup if os.path.isdir(self.build_dir): shutil.rmtree(self.build_dir) # get content type. if is_file(self.download_url): path = fileurl_to_path(self.download_url) self.content_type = mimetypes.guess_type(path)[0] else: headerinfo = get_headerinfo_from_url(self.download_url) self.content_type = headerinfo['content-type'] if is_html(self.content_type): # note: maybe got 404 or 503 http status code. logger.error("Invalid content-type: `%s`" % self.content_type) return if os.path.isdir(self.install_dir): logger.info("You have already installed `%s`" % self.pkg.name) return self.download_and_extract() logger.info("\nThis could take a while. You can run the following command on another shell to track the status:") logger.info(" tail -f %s\n" % self.logfile) logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir)) if self.pkg.type == 'pypy': shutil.copytree(self.build_dir, self.install_dir) else: try: self.patch() self.configure() self.make() self.make_install() except: rm_r(self.install_dir) logger.error("Failed to install %s. Check %s to see why." % (self.pkg.name, self.logfile)) sys.exit(1) self.symlink() logger.info("\nInstalled %(pkgname)s successfully." % {"pkgname":self.pkg.name})