2019-09-04 17:22:28 -03:00
|
|
|
#!/usr/bin/python3
|
2008-10-02 22:35:52 +01:00
|
|
|
|
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
|
|
|
#
|
|
|
|
# ##################################################################
|
|
|
|
|
2023-01-30 23:10:31 +01:00
|
|
|
# pylint: disable=invalid-name
|
|
|
|
# pylint: enable=invalid-name
|
|
|
|
|
2023-01-31 13:33:18 +01:00
|
|
|
import argparse
|
2019-09-04 19:17:00 -03:00
|
|
|
import subprocess
|
2008-10-02 22:35:52 +01:00
|
|
|
import sys
|
2011-05-24 20:22:37 +02:00
|
|
|
|
2018-10-12 18:54:07 -04:00
|
|
|
from ubuntutools import getLogger
|
2023-01-30 19:45:36 +01:00
|
|
|
|
2021-02-01 18:26:13 -05:00
|
|
|
Logger = getLogger()
|
2018-10-12 18:54:07 -04:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2008-10-02 22:35:52 +01:00
|
|
|
def extract(iso, path):
|
2023-01-30 19:45:36 +01:00
|
|
|
command = ["isoinfo", "-R", "-i", iso, "-x", path]
|
|
|
|
pipe = subprocess.run(
|
2023-01-31 15:51:29 +01:00
|
|
|
command, check=False, encoding="utf-8", stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
2023-01-30 19:45:36 +01:00
|
|
|
)
|
2008-10-02 22:35:52 +01:00
|
|
|
|
2010-12-18 12:52:24 +01:00
|
|
|
if pipe.returncode != 0:
|
2019-02-11 14:30:01 -05:00
|
|
|
sys.stderr.write(pipe.stderr)
|
2010-12-18 12:59:08 +01:00
|
|
|
sys.exit(pipe.returncode)
|
2008-10-02 22:35:52 +01:00
|
|
|
|
2019-02-11 14:30:01 -05:00
|
|
|
return pipe.stdout
|
2008-10-02 22:35:52 +01:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2008-10-02 22:35:52 +01:00
|
|
|
def main():
|
2023-01-31 13:33:18 +01:00
|
|
|
desc = "Given an ISO, %(prog)s will display the Ubuntu version information"
|
|
|
|
parser = argparse.ArgumentParser(usage="%(prog)s [options] iso...", description=desc)
|
|
|
|
parser.add_argument("isos", nargs="*", help=argparse.SUPPRESS)
|
|
|
|
args = parser.parse_args()
|
2010-12-18 12:52:24 +01:00
|
|
|
err = False
|
2008-10-02 22:35:52 +01:00
|
|
|
|
2023-01-31 13:33:18 +01:00
|
|
|
for iso in args.isos:
|
|
|
|
if len(args.isos) > 1:
|
2023-01-30 19:45:36 +01:00
|
|
|
prefix = "%s:" % iso
|
2010-12-18 12:52:24 +01:00
|
|
|
else:
|
2023-01-30 19:45:36 +01:00
|
|
|
prefix = ""
|
2008-10-27 12:10:48 +00:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
version = extract(iso, "/.disk/info")
|
2008-10-27 12:10:48 +00:00
|
|
|
|
2010-12-18 12:52:24 +01:00
|
|
|
if len(version) == 0:
|
2023-01-31 11:13:07 +01:00
|
|
|
Logger.error("%s does not appear to be an Ubuntu ISO", iso)
|
2010-12-18 12:52:24 +01:00
|
|
|
err = True
|
|
|
|
continue
|
2008-10-27 12:10:48 +00:00
|
|
|
|
2018-10-12 18:54:07 -04:00
|
|
|
Logger.info(prefix + version)
|
2008-10-27 12:10:48 +00:00
|
|
|
|
2010-12-18 12:52:24 +01:00
|
|
|
if err:
|
|
|
|
sys.exit(1)
|
2008-10-02 22:35:52 +01:00
|
|
|
|
2017-05-01 00:20:03 +02:00
|
|
|
|
2023-01-30 19:45:36 +01:00
|
|
|
if __name__ == "__main__":
|
2010-12-18 12:52:24 +01:00
|
|
|
main()
|
|
|
|
sys.exit(0)
|