def download_unpack(self): content_type = self.content_type if is_html(content_type): logger.error("Invalid content-type: `%s`" % content_type) sys.exit(1) 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)) if os.path.isdir(self.build_dir): shutil.rmtree(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: msg = Link(self.download_url).show_msg try: dl = Downloader() dl.download(msg, self.download_url, self.download_file) except: unlink(self.download_file) logger.info("\nInterrupt to abort. `%s`" % (self.download_url)) sys.exit(1) # unpack if not unpack_downloadfile(self.content_type, self.download_file, self.build_dir): sys.exit(1)
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 are 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) self.patch() logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir)) try: self.configure() self.make() self.make_install() except: rm_r(self.install_dir) logger.error("Failed to install %s. See %s to see why." % (self.pkg.name, self.logfile)) logger.log(" pythonbrew install --force %s" % self.pkg.version) sys.exit(1) self.symlink() self.install_setuptools() logger.info( "\nInstalled %(pkgname)s successfully. Run the following command to switch to %(pkgname)s." % {"pkgname": self.pkg.name}) logger.info(" pythonbrew switch %s" % self.pkg.alias)
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 are 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) self.patch() logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir)) try: self.configure() self.make() self.make_install() except: rm_r(self.install_dir) logger.error("Failed to install %s. See %s to see why." % (self.pkg.name, self.logfile)) logger.log(" pythonbrew install --force %s" % self.pkg.version) sys.exit(1) self.symlink() self.install_setuptools() logger.info( "\nInstalled %(pkgname)s successfully. Run the following command to switch to %(pkgname)s." % {"pkgname": self.pkg.name} ) logger.info(" pythonbrew switch %s" % self.pkg.alias)
def download(self): content_type = self.content_type if is_html(content_type): logger.error("Invalid content-type: `%s`" % content_type) sys.exit(1) if os.path.isfile(self.download_file): logger.info("Use the previously fetched %s" % (self.download_file)) return msg = Link(self.download_url).show_msg try: dl = Downloader() dl.download( msg, self.download_url, self.download_file ) except: unlink(self.download_file) logger.info("\nInterrupt to abort. `%s`" % (self.download_url)) sys.exit(1)