Skip to content

Instantly share code, notes, and snippets.

@eiszfuchs
Created May 24, 2012 14:32
Show Gist options
  • Save eiszfuchs/2781901 to your computer and use it in GitHub Desktop.
Save eiszfuchs/2781901 to your computer and use it in GitHub Desktop.
Grab the latest Chromium build from the net!
import urllib.request, urllib.parse, urllib.error
import math
# change os_url & file_base_url if you aren't on a Windows PC
server_url_base = "http://commondatastorage.googleapis.com/chromium-browser-snapshots/"
os_url = "Win/" # "Mac/"
file_base_url = "/chrome-win32.zip" # "/chrome-mac.zip"
latest_url = server_url_base + os_url + "LAST_CHANGE"
f = urllib.request.urlopen(latest_url)
fbytes = f.read()
latest_num = fbytes.decode("utf8")
file_url = server_url_base + os_url + latest_num + file_base_url
file_name = "chrome-b" + latest_num + ".zip"
u = urllib.request.urlopen(file_url)
f = open(file_name, 'wb')
meta = dict(u.info())
file_size = int(meta["Content-Length"])
bar_length = 30
file_size_dl = 0
block_sz = 8192
status_header = "Loading Chromium, Build " + latest_num
print(status_header)
while True:
buffer = u.read(block_sz)
if not buffer:
break
file_size_dl += len(buffer)
f.write(buffer)
status = "%05.1f%%" % (file_size_dl * 100. / file_size)
progress_length = math.floor((file_size_dl / file_size) * bar_length)
status += ' [' + ('=' * progress_length) + (' ' * (bar_length - progress_length)) + ']'
print(status, end='\r')
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment