Exemplo n.º 1
0
 def run_command(self, options, args):
     if args:
         version = args[0]
     else:
         version = get_stable_version()
         
     # check for latest version
     if version <= VERSION:
         logger.info("You are already running the installed latest version of pythonbrew.")
         sys.exit()
     
     download_url = get_pythonbrew_update_url(version)
     if not download_url:
         logger.error("`%s` of pythonbrew not found." % version)
         sys.exit(1)
     resp = get_response_from_url(download_url)
     content_type = resp.info()['content-type']
     if not is_gzip(content_type, Link(download_url).filename):
         logger.error("Invalid content-type: `%s`" % content_type)
         sys.exit(1)
     
     filename = "pythonbrew-%s" % version
     distname = "%s.tgz" % filename
     download_file = os.path.join(PATH_DISTS, distname)
     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 unpack_downloadfile(content_type, download_file, extract_dir):
         sys.exit(1)
     
     try:
         installer_path = "%s/pythonbrew" % (extract_dir)
         logger.info("Installing %s into %s" % (extract_dir, ROOT))
         PythonbrewInstaller().install(installer_path)
     except:
         logger.error("Failed to update pythonbrew.")
         raise
         sys.exit(1)
     logger.info("The pythonbrew has been updated.")
Exemplo n.º 2
0
 def __init__(self, arg, options):
     if is_url(arg):
         self.download_url = arg
         filename = Link(self.download_url).filename
         pkg = Package(splitext(filename)[0])
     else:
         pkg = Package(arg)
         self.download_url = get_python_version_url(pkg.version)
         if not self.download_url:
             logger.info("Unknown python version: `%s`" % pkg.name)
             sys.exit(1)
         filename = Link(self.download_url).filename
     self.pkg = pkg
     self.install_dir = "%s/%s" % (PATH_PYTHONS, pkg.name)
     self.build_dir = "%s/%s" % (PATH_BUILD, pkg.name)
     self.download_file = "%s/%s" % (PATH_DISTS, filename)
     resp = get_response_from_url(self.download_url)
     self.content_type = resp.info()['content-type']
     self.options = options
     self.logfile = "%s/build.log" % PATH_LOG