Skip to content

Instantly share code, notes, and snippets.

@asenchi
Forked from dekz/chromium updater.py
Created June 12, 2009 06:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save asenchi/128477 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# Chromium Updater
# Download and install the newest Chromium build from http://chromium.org
# on Mac OS X.
import urllib2, os.path, sys
BASE_URL = 'http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/'
UPDATE_URL = 'http://build.chromium.org/buildbot/snapshots/chromium-rel-mac/LATEST'
DOWNLOAD_PATH = os.path.expanduser('~/Downloads/Chromium Updater')
def latest_build():
return urllib2.urlopen(UPDATE_URL).read()
def install():
print 'Extracting files ...'
os.system('unzip -q chrome-mac.zip')
print 'Removing old files. You might be asked to enter your password.'
os.system('sudo rm -rf /Applications/Chromium.app')
print 'Installing files. You might be asked to enter your password.'
os.system('sudo cp -r chrome-mac/ /Applications/')
print 'Removing old files ...'
os.system('rm -rf chrome-mac')
print 'All done!'
def update():
print 'Looking for latest build ...'
build = latest_build()
print 'Latest build is %s.' % (build)
build_download_path = os.path.join(DOWNLOAD_PATH, build)
if not os.path.exists(DOWNLOAD_PATH):
os.mkdir(DOWNLOAD_PATH)
if not os.path.exists(build_download_path) :
os.mkdir(build_download_path)
if os.path.exists(os.path.join(build_download_path, 'chrome-mac.zip')):
print 'You\'re using the newest build. Reinstalling this build ...'
os.chdir(build_download_path)
install()
print 'Reinstalled revision %s' % (build)
sys.exit()
os.chdir(build_download_path)
download_url = BASE_URL + build + '/' + 'chrome-mac.zip'
command = 'curl ' + download_url + ' -o chrome-mac.zip'
print 'Starting download of file %s' % (download_url)
os.system(command)
install()
print 'Upgraded to revision %s' % (build)
if __name__ == '__main__':
update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment