update version 0.6.1

This commit is contained in:
utahta
2010-11-18 01:29:24 +09:00
parent 53236cc001
commit 0bc17f56db
6 changed files with 33 additions and 24 deletions
+8 -6
View File
@@ -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)