lookup imagemagick tool, and loudly fail if it doesn't work
This commit is contained in:
@@ -11,10 +11,17 @@ import subprocess
|
||||
|
||||
ROOT = os.path.dirname(os.path.abspath(__file__))
|
||||
imagecompare = f'{ROOT}/imagecompare'
|
||||
magick = f'magick' # set path for imagemagick if need
|
||||
WORKDIR = f'{ROOT}/work'
|
||||
REPORT_ROOT = f'{ROOT}' # FIXME should be workdir?
|
||||
|
||||
def get_imagemagick_convert_cmd() -> str:
|
||||
if shutil.which("magick"):
|
||||
return "magick"
|
||||
if shutil.which("convert"):
|
||||
return "convert"
|
||||
raise RuntimeError("No ImageMagick binary found (tried: magick, convert)")
|
||||
convert = get_imagemagick_convert_cmd()
|
||||
|
||||
# TODO rename to <map>_<description>_<issue(opt)>
|
||||
saves = []
|
||||
for (_, _, files) in os.walk(os.path.join(ROOT, 'save')):
|
||||
@@ -184,6 +191,7 @@ def command_png():
|
||||
new_gold_base = f'{WORKDIR}/gold'
|
||||
mkdir_p(new_gold_base)
|
||||
with concurrent.futures.ThreadPoolExecutor() as executor:
|
||||
futures = []
|
||||
for test in args.tests:
|
||||
for channel, _ in channels.items():
|
||||
image_base = f'{test}_{channel}'
|
||||
@@ -191,7 +199,10 @@ def command_png():
|
||||
image_new_gold = f'{new_gold_base}/{image_base}.png'
|
||||
|
||||
# TODO if verbose: print(f'convert to {image_new_gold}')
|
||||
executor.submit(subprocess.run, [magick, image_test, '-auto-orient', image_new_gold], check=True)
|
||||
future = executor.submit(subprocess.run, [convert, image_test, '-auto-orient', image_new_gold], check=True)
|
||||
futures.append(future)
|
||||
for f in concurrent.futures.as_completed(futures):
|
||||
f.result()
|
||||
|
||||
def command_run():
|
||||
compile()
|
||||
|
||||
Reference in New Issue
Block a user