-
-
Save ishan-marikar/f5bb2a8708602d10799f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
import sys | |
import urllib | |
import subprocess | |
def reporthook(count, block_size, total_size): | |
sys.stdout.write("\r%6.2f %% [%i/%i]"%((count * block_size * 100.0 / | |
total_size), count * block_size, total_size)) | |
sys.stdout.flush() | |
file_name = "atom-amd64.deb" | |
base_url = "https://github.com/atom/atom/releases" | |
url_info = urllib.urlopen("%s/latest"%base_url) | |
resolved = url_info.geturl() | |
tag = resolved.split('/')[-1] | |
version = lambda s: list(map(int, s.split('.'))) | |
latest = version(tag[1:]) # remove 'v' in v0.1.2 | |
current = version(subprocess.check_output(['atom', '--version']).strip()) | |
if latest > current: | |
print("downloading %s current is %s"%(tag, current)) | |
file_path, _ = urllib.urlretrieve("%s/download/%s/%s"% | |
(base_url, tag, file_name), file_name, reporthook) | |
print("install %s"%file_path) | |
subprocess.check_output(['xdg-open', file_path]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment