Skip to content

Instantly share code, notes, and snippets.

@elmarx
Created January 16, 2011 22:51
Show Gist options
  • Save elmarx/782231 to your computer and use it in GitHub Desktop.
Save elmarx/782231 to your computer and use it in GitHub Desktop.
Fetches the most recent intellij idea x version if not yet installed, to use in daily anacron job or simliar. Very basic functionality, very specific to my setup. But should be easy to adopt.
#!/usr/bin/env python3
import re
from urllib import request
import os
WEBSITE = "http://confluence.jetbrains.net/display/IDEADEV/IDEA+X+EAP"
MATCH = r".*(http://download\.jetbrains\.com/idea/ideaIU-(\d+\.\d+)\.tar\.gz).*"
with request.urlopen(WEBSITE) as h:
for line in [x.decode() for x in h.readlines()]:
m = re.match(MATCH, line)
if m:
url = m.groups()[0]
version = m.groups()[1]
if not os.path.exists('/opt/idea-IU-%s' % version):
print('Idea will be upgraded to version %s:' % version)
os.system('wget -qO - %s | sudo tar xzf - -C /opt' % url)
os.system('sudo rm /opt/idea')
os.system('sudo ln -s /opt/idea-IU-%s /opt/idea' % version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment