mirror of
				https://git.launchpad.net/ubuntu-dev-tools
				synced 2025-11-04 07:54:03 +00:00 
			
		
		
		
	pylint complains about C0209: Formatting a regular string which could be a f-string (consider-using-f-string) Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
		
			
				
	
	
		
			77 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Python
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/python3
 | 
						|
 | 
						|
# 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
 | 
						|
# as published by the Free Software Foundation, version 2
 | 
						|
# 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.
 | 
						|
#
 | 
						|
# See file /usr/share/common-licenses/GPL-2 for more details.
 | 
						|
#
 | 
						|
# ##################################################################
 | 
						|
 | 
						|
# pylint: disable=invalid-name
 | 
						|
# pylint: enable=invalid-name
 | 
						|
 | 
						|
import argparse
 | 
						|
import subprocess
 | 
						|
import sys
 | 
						|
 | 
						|
from ubuntutools import getLogger
 | 
						|
 | 
						|
Logger = getLogger()
 | 
						|
 | 
						|
 | 
						|
def extract(iso, path):
 | 
						|
    command = ["isoinfo", "-R", "-i", iso, "-x", path]
 | 
						|
    pipe = subprocess.run(
 | 
						|
        command, check=False, encoding="utf-8", stdout=subprocess.PIPE, stderr=subprocess.PIPE
 | 
						|
    )
 | 
						|
 | 
						|
    if pipe.returncode != 0:
 | 
						|
        sys.stderr.write(pipe.stderr)
 | 
						|
        sys.exit(pipe.returncode)
 | 
						|
 | 
						|
    return pipe.stdout
 | 
						|
 | 
						|
 | 
						|
def main():
 | 
						|
    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()
 | 
						|
    err = False
 | 
						|
 | 
						|
    for iso in args.isos:
 | 
						|
        if len(args.isos) > 1:
 | 
						|
            prefix = f"{iso}:"
 | 
						|
        else:
 | 
						|
            prefix = ""
 | 
						|
 | 
						|
        version = extract(iso, "/.disk/info")
 | 
						|
 | 
						|
        if len(version) == 0:
 | 
						|
            Logger.error("%s does not appear to be an Ubuntu ISO", iso)
 | 
						|
            err = True
 | 
						|
            continue
 | 
						|
 | 
						|
        Logger.info(prefix + version)
 | 
						|
 | 
						|
    if err:
 | 
						|
        sys.exit(1)
 | 
						|
 | 
						|
 | 
						|
if __name__ == "__main__":
 | 
						|
    main()
 | 
						|
    sys.exit(0)
 |