ubuntu-dev-tools/ubuntu-iso

62 lines
1.6 KiB
Plaintext
Raw Normal View History

#!/usr/bin/python
2008-10-03 14:52:36 +01:00
# ubuntuiso - tool to examine Ubuntu CD (ISO) installation media
# Copyright (C) 2008 Canonical Ltd.
# Author: Matt Zimmerman <mdz@ubuntu.com>
#
# ##################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
2008-10-03 14:54:11 +01:00
# as published by the Free Software Foundation, version 2
# of the License.
2010-12-03 00:06:43 +01:00
#
2008-10-03 14:52:36 +01:00
# 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.
2010-12-03 00:06:43 +01:00
#
2008-10-03 14:54:11 +01:00
# See file /usr/share/common-licenses/GPL-2 for more details.
2008-10-03 14:52:36 +01:00
#
# ##################################################################
import sys
import subprocess
def extract(iso, path):
2010-12-18 12:52:24 +01:00
command = ['isoinfo', '-R', '-i', iso, '-x', path]
pipe = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = pipe.communicate()
2010-12-18 12:52:24 +01:00
if pipe.returncode != 0:
raise Exception, stderr
2010-12-18 12:52:24 +01:00
return stdout
def main():
2010-12-18 12:52:24 +01:00
isos = sys.argv[1:]
err = False
2010-12-18 12:52:24 +01:00
for iso in isos:
if len(isos) > 1:
prefix = '%s:' % iso
else:
prefix = ''
2010-12-18 12:52:24 +01:00
version = extract(iso, '/.disk/info')
2010-12-18 12:52:24 +01:00
if len(version) == 0:
print >>sys.stderr, '%s does not appear to be an Ubuntu ISO' % iso
err = True
continue
2010-12-18 12:52:24 +01:00
print prefix + version
2010-12-18 12:52:24 +01:00
if err:
sys.exit(1)
if __name__ == '__main__':
2010-12-18 12:52:24 +01:00
main()
sys.exit(0)