#!/usr/bin/python # # testdrive-select-iso - present a list and select an ISO for testdriving # Copyright (C) 2009 Canonical Ltd. # Copyright (C) 2009 Dustin Kirkland # # Authors: Dustin Kirkland # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 3 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . import commands, time, os PKG = "testdrive" ARCH = commands.getoutput("uname -m | grep -qs x86_64 && echo amd64 || echo i386") RELEASE = "lucid" ISO = [] ISO.append({"name":"Ubuntu Desktop (i386)", "url":"rsync://cdimage.ubuntu.com/cdimage/daily-live/current/%s-desktop-i386.iso"%(RELEASE)}) ISO.append({"name":"Ubuntu Server (i386)", "url":"rsync://cdimage.ubuntu.com/cdimage/ubuntu-server/daily/current/%s-server-i386.iso"%(RELEASE)}) ISO.append({"name":"Ubuntu Alternate (i386)", "url":"rsync://cdimage.ubuntu.com/cdimage/daily/current/%s-alternate-i386.iso"%(RELEASE)}) ISO.append({"name":"Ubuntu DVD (i386)", "url":"rsync://cdimage.ubuntu.com/cdimage/dvd/current/%s-dvd-i386.iso"%(RELEASE)}) if ARCH == "amd64": ISO.append({"name":"Ubuntu Desktop (amd64)", "url":"rsync://cdimage.ubuntu.com/cdimage/daily-live/current/%s-desktop-amd64.iso"%(RELEASE)}) ISO.append({"name":"Ubuntu Server (amd64)", "url":"rsync://cdimage.ubuntu.com/cdimage/ubuntu-server/daily/current/%s-server-amd64.iso"%(RELEASE)}) ISO.append({"name":"Ubuntu Alternate (amd64)", "url":"rsync://cdimage.ubuntu.com/cdimage/daily/current/%s-alternate-amd64.iso"%(RELEASE)}) ISO.append({"name":"Ubuntu DVD (amd64)", "url":"rsync://cdimage.ubuntu.com/cdimage/dvd/current/%s-dvd-amd64.iso"%(RELEASE)}) ISO.append({"name":"Ubuntu Netbook Remix (i386)", "url":"rsync://cdimage.ubuntu.com/cdimage/ubuntu-netbook-remix/daily-live/current/%s-netbook-remix-i386.iso"%(RELEASE)}) # These are problematic, because the names are all the same ... lucid-desktop-i386.iso # Need to rename the destination ISO accordingly #rsync://cdimage.ubuntu.com/cdimage/kubuntu/daily-live/current/%s-desktop-%s.iso #rsync://cdimage.ubuntu.com/cdimage/xubuntu/daily-live/current/%s-desktop-%s.iso #rsync://cdimage.ubuntu.com/cdimage/mythbuntu/daily-live/current/%s-desktop-%s.iso #rsync://cdimage.ubuntu.com/cdimage/kubuntu-netbook/daily-live/current/%s-netbook-i386.iso" while 1: i = 1 for iso in ISO: print(" %d. %s (%s)" % (i, iso["name"], RELEASE)) filename = os.path.basename(iso["url"]) path = "%s/.cache/%s/%s" % (os.environ["HOME"], PKG, filename) if os.path.exists(path): print(" +-cache--> [%s] %s" % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(os.path.getmtime(path))), filename)) i=i+1 print(" %d. Other (prompt for ISO URL)" % i) try: input = raw_input("\nSelect an ISO to testdrive: ") choice = int(input) except KeyboardInterrupt: print("\n") exit(0) except: print("\nERROR: Invalid input\n") continue if choice == i: url = raw_input("\nEnter an ISO URL to testdrive: ") break elif choice in range(1, i): url = ISO[choice-1]["url"] break else: print("\nERROR: Invalid selection\n") os.system("testdrive -u %s" % url)