mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 23:30:18 +00:00
update version 0.6.1
This commit is contained in:
@@ -5,8 +5,8 @@ from pythonbrew.define import PATH_DISTS, VERSION, ROOT,\
|
||||
PATH_BUILD
|
||||
from pythonbrew.log import logger
|
||||
from pythonbrew.downloader import Downloader, get_pythonbrew_update_url,\
|
||||
get_response_from_url
|
||||
from pythonbrew.util import rm_r, is_html, unpack_downloadfile
|
||||
get_response_from_url, get_stable_version
|
||||
from pythonbrew.util import rm_r, unpack_downloadfile, Link, is_gzip
|
||||
from pythonbrew.installer import PythonbrewInstaller
|
||||
|
||||
class UpdateCommand(Command):
|
||||
@@ -15,9 +15,10 @@ class UpdateCommand(Command):
|
||||
summary = "Upgrades pythonbrew to the latest version"
|
||||
|
||||
def run_command(self, options, args):
|
||||
version = "head"
|
||||
if args:
|
||||
version = args[0]
|
||||
else:
|
||||
version = get_stable_version()
|
||||
|
||||
# check for latest version
|
||||
if version <= VERSION:
|
||||
@@ -30,11 +31,12 @@ class UpdateCommand(Command):
|
||||
sys.exit(1)
|
||||
resp = get_response_from_url(download_url)
|
||||
content_type = resp.info()['content-type']
|
||||
if is_html(content_type):
|
||||
if not is_gzip(content_type, Link(download_url).filename):
|
||||
logger.error("Invalid content-type: `%s`" % content_type)
|
||||
sys.exit(1)
|
||||
|
||||
distname = "pythonbrew.tgz"
|
||||
filename = "pythonbrew-%s" % version
|
||||
distname = "%s.tgz" % filename
|
||||
download_file = os.path.join(PATH_DISTS, distname)
|
||||
try:
|
||||
d = Downloader()
|
||||
@@ -43,7 +45,7 @@ class UpdateCommand(Command):
|
||||
logger.error("Failed to download. `%s`" % download_url)
|
||||
sys.exit(1)
|
||||
|
||||
extract_dir = os.path.join(PATH_BUILD, "pythonbrew")
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user