From 6eedfd2fdc84667ee80b4247d9439def0215d474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Pr=C3=BCsse?= Date: Wed, 1 Nov 2023 14:35:59 -0300 Subject: [PATCH] Improve error messages from "inv qrc" ASIM-5273 --- .gitignore | 3 +++ tasks.py | 22 ++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9cafdac8..88afd998 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,9 @@ target/ # PyCharm files .idea/ +# Underling mxgraph library that could have been cloned. +/mxgraph/ + # Generate Qt resource files resource_*.qrc resource_*.py diff --git a/tasks.py b/tasks.py index 9d97a888..01b7fce5 100644 --- a/tasks.py +++ b/tasks.py @@ -60,11 +60,29 @@ def create_web_resource(resource_name, src_dir): print_message('{}* generated {}'.format(indent * 2, py_file)) mxgraph = os.environ.get('MXGRAPHPATH', None) - if mxgraph is None: + if mxgraph is not None: + if not os.path.isdir(mxgraph): + raise IOError( + "Unable to determine MxGraph to use:" + " directory obtained from `MXGRAPHPATH` env var does not exist" + ) + + else: env_dir = deploy.get_conda_env_path() if env_dir is None: - raise IOError("Unable to determine MxGraph mxgraph in " "environment") + raise IOError( + "Unable to determine MxGraph to use:" + " no `MXGRAPHPATH` env var defined" + " and no conda environment active" + ) + mxgraph = '{env_dir}/mxgraph'.format(env_dir=env_dir) + if not os.path.isdir(mxgraph): + raise IOError( + "Unable to determine MxGraph to use:" + " no `MXGRAPHPATH` env var defined" + " and not located in active conda environment" + ) create_web_resource( resource_name='mxgraph', src_dir='{folder}/javascript/src'.format(folder=mxgraph)