Skip to content

Instantly share code, notes, and snippets.

@naufraghi
Created November 24, 2010 12:10
Show Gist options
  • Save naufraghi/713558 to your computer and use it in GitHub Desktop.
Save naufraghi/713558 to your computer and use it in GitHub Desktop.
Download latest nomachine nx debian packages
#!/usr/bin/python
import os
import sys
import urllib
import re
import glob
import platform
def download(plat):
# <A HREF="http://www.nomachine.com/download-package.php?Prod_Id=541" CLASS="link2">
# <b>NX Free Edition for Linux DEB - i386</b>&nbsp;<br>
print "downloading index..."
index = urllib.urlopen("http://www.nomachine.com/select-package.php?os=linux&id=1").read()
pid = re.findall("DEB - %s.*?Prod_Id=(\d+)" % plat, index, re.DOTALL)[0]
txt = urllib.urlopen("http://www.nomachine.com/download-package.php?Prod_Id=%s" % pid).read()
debs = re.findall(r'\"([^\"]*\.deb)\"', txt)
def step(*args):
sys.stdout.write(".")
sys.stdout.flush()
for deb in set(debs):
dest = deb.split("/")[-1]
if not os.path.exists(dest):
print "downloading %s..." % deb
urllib.urlretrieve(deb, dest, step)
print
else:
print "file %s exists" % dest
yield dest
if __name__ == "__main__":
if len(sys.argv) != 2:
plat = platform.machine()
else:
plat = sys.argv[1]
debs = ' '.join(download(plat))
print "Install using: sudo dpkg -i {0}".format(debs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment