Update-catalog.py: —quiet option

This commit is contained in:
James Turner 2018-10-17 11:04:11 +01:00
parent feae4a2d56
commit 391ceaea11

View File

@ -24,6 +24,8 @@ parser.add_argument("--no-update",
action="store_true") action="store_true")
parser.add_argument("--clean", help="Force regeneration of all zip files", parser.add_argument("--clean", help="Force regeneration of all zip files",
action="store_true") action="store_true")
parser.add_argument("--quiet", help="Only print warnings and errors",
action="store_true")
parser.add_argument("dir", help="Catalog directory") parser.add_argument("dir", help="Catalog directory")
args = parser.parse_args() args = parser.parse_args()
@ -64,7 +66,8 @@ def scan_dir_for_change_date_mtime(path):
return maxsec return maxsec
def make_aircraft_zip(repo_path, name, zip_file): def make_aircraft_zip(repo_path, name, zip_file):
print "Updating:", name + '.zip' if (not args.quiet):
print "Updating:", name + '.zip'
savedir = os.getcwd() savedir = os.getcwd()
os.chdir(repo_path) os.chdir(repo_path)
if os.path.exists(zip_file): if os.path.exists(zip_file):
@ -136,7 +139,8 @@ def process_aircraft_dir(name, repo_path):
(package, variants) = catalog.scan_aircraft_dir(aircraft_dir, includes) (package, variants) = catalog.scan_aircraft_dir(aircraft_dir, includes)
if package == None: if package == None:
print "skipping:", name, "(no -set.xml files)" if not args.quiet:
print "skipping:", name, "(no -set.xml files)"
return return
print "%s:" % name, print "%s:" % name,
@ -168,11 +172,13 @@ def process_aircraft_dir(name, repo_path):
or dir_mtime > os.path.getmtime(zipfile) \ or dir_mtime > os.path.getmtime(zipfile) \
or args.clean: or args.clean:
# rebuild zip file # rebuild zip file
print "updating:", zipfile if not args.quiet:
print "updating:", zipfile
make_aircraft_zip(repo_path, name, zipfile) make_aircraft_zip(repo_path, name, zipfile)
md5sum = get_md5sum(zipfile) md5sum = get_md5sum(zipfile)
else: else:
print "(no change)" if not args.quiet:
print "(no change)"
if md5sum == "": if md5sum == "":
md5sum = get_md5sum(zipfile) md5sum = get_md5sum(zipfile)
filesize = os.path.getsize(zipfile) filesize = os.path.getsize(zipfile)
@ -300,7 +306,8 @@ for scm in scm_list:
names = os.listdir(repo_path) names = os.listdir(repo_path)
for name in sorted(names, key=lambda s: s.lower()): for name in sorted(names, key=lambda s: s.lower()):
if name in skip_list: if name in skip_list:
print "skipping:", name if not args.quiet:
print "skipping:", name
continue continue
# process each aircraft in turn # process each aircraft in turn