Created
March 21, 2017 10:23
-
-
Save syxolk/333c3d947ed40ca60d1570ebcad8db83 to your computer and use it in GitHub Desktop.
Compare the latest release with the currently installed version of Atom
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 python3 | |
import requests | |
import subprocess | |
def get_latest(): | |
response = requests.get("https://github.com/atom/atom/releases/latest") | |
return response.url[response.url.rfind("/")+2:] | |
def get_current(): | |
output = subprocess.check_output(["atom", "--version"]) | |
for line in output.decode().splitlines(): | |
if line.split(":")[0].strip() == "Atom": | |
return line.split(":")[1].strip() | |
return None | |
if __name__ == "__main__": | |
current = get_current() | |
print("Current version: {0}".format(current)) | |
latest = get_latest() | |
print("Latest version: {0}".format(latest)) | |
print() | |
if latest != current: | |
print("\033[31m-> Needs update!\033[30m") | |
else: | |
print("\033[32mYou are up to date\033[30m") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment