From 7b16cf5d3977d34768434a58db7b14e5cd8c633a Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Tue, 19 Feb 2019 11:34:51 -0800 Subject: [PATCH] Dynamically determine valid Seed Program names and provide better error message if an unknown Seed Program is given to --seedprogram --- installinstallmacos.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/installinstallmacos.py b/installinstallmacos.py index d1a10a2..3d5793b 100755 --- a/installinstallmacos.py +++ b/installinstallmacos.py @@ -73,6 +73,15 @@ def get_seed_catalog(seedname='DeveloperSeed'): return '' +def get_seeding_programs(): + '''Returns the list of seeding program names''' + try: + seed_catalogs = plistlib.readPlist(SEED_CATALOGS_PLIST) + return seed_catalogs.keys() + except (OSError, ExpatError, AttributeError, KeyError): + return '' + + def get_default_catalog(): '''Returns the default softwareupdate catalog for the current OS''' darwin_major = os.uname()[2].split('.')[0] @@ -401,7 +410,7 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument('--seedprogram', default='', help='Which Seed Program catalog to use. Valid values ' - 'are CustomerSeed, DeveloperSeed, and PublicSeed.') + 'are %s.' % ', '.join(get_seeding_programs())) parser.add_argument('--catalogurl', default='', help='Software Update catalog URL. This option ' 'overrides any seedprogram option.') @@ -431,6 +440,9 @@ def main(): print >> sys.stderr, ( 'Could not find a catalog url for seed program %s' % args.seedprogram) + print >> sys.stderr, ( + 'Valid seeding programs are: %s' + % ', '.join(get_seeding_programs())) exit(-1) else: su_catalog_url = get_default_catalog()