mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
🐛 fix error reports in silent mode
This commit is contained in:
parent
0b8207a5f2
commit
7992ba6969
1 changed files with 26 additions and 25 deletions
51
start.py
51
start.py
|
|
@ -140,8 +140,8 @@ import certifi # noqa: E402
|
|||
if sys.__stdout__:
|
||||
term = blessed.Terminal()
|
||||
|
||||
def _print(message: str):
|
||||
if silent_mode:
|
||||
def _print(message: str, force=False):
|
||||
if silent_mode and not force:
|
||||
return
|
||||
if message.startswith("!!! "):
|
||||
print(f'{term.orangered2("!!! ")}{message[4:]}')
|
||||
|
|
@ -507,8 +507,8 @@ def _process_arguments() -> tuple:
|
|||
not use_version_value
|
||||
or not use_version_value.startswith("=")
|
||||
):
|
||||
_print("!!! Please use option --use-version like:")
|
||||
_print(" --use-version=3.0.0")
|
||||
_print("!!! Please use option --use-version like:", True)
|
||||
_print(" --use-version=3.0.0", True)
|
||||
sys.exit(1)
|
||||
|
||||
version_str = use_version_value[1:]
|
||||
|
|
@ -525,14 +525,14 @@ def _process_arguments() -> tuple:
|
|||
break
|
||||
|
||||
if use_version is None:
|
||||
_print("!!! Requested version isn't in correct format.")
|
||||
_print("!!! Requested version isn't in correct format.", True)
|
||||
_print((" Use --list-versions to find out"
|
||||
" proper version string."))
|
||||
" proper version string."), True)
|
||||
sys.exit(1)
|
||||
|
||||
if arg == "--validate-version":
|
||||
_print("!!! Please use option --validate-version like:")
|
||||
_print(" --validate-version=3.0.0")
|
||||
_print("!!! Please use option --validate-version like:", True)
|
||||
_print(" --validate-version=3.0.0", True)
|
||||
sys.exit(1)
|
||||
|
||||
if arg.startswith("--validate-version="):
|
||||
|
|
@ -543,9 +543,9 @@ def _process_arguments() -> tuple:
|
|||
sys.argv.remove(arg)
|
||||
commands.append("validate")
|
||||
else:
|
||||
_print("!!! Requested version isn't in correct format.")
|
||||
_print("!!! Requested version isn't in correct format.", True)
|
||||
_print((" Use --list-versions to find out"
|
||||
" proper version string."))
|
||||
" proper version string."), True)
|
||||
sys.exit(1)
|
||||
|
||||
if "--list-versions" in sys.argv:
|
||||
|
|
@ -556,7 +556,7 @@ def _process_arguments() -> tuple:
|
|||
# this is helper to run igniter before anything else
|
||||
if "igniter" in sys.argv:
|
||||
if os.getenv("OPENPYPE_HEADLESS_MODE") == "1":
|
||||
_print("!!! Cannot open Igniter dialog in headless mode.")
|
||||
_print("!!! Cannot open Igniter dialog in headless mode.", True)
|
||||
sys.exit(1)
|
||||
|
||||
return_code = igniter.open_dialog()
|
||||
|
|
@ -606,9 +606,9 @@ def _determine_mongodb() -> str:
|
|||
if not openpype_mongo:
|
||||
_print("*** No DB connection string specified.")
|
||||
if os.getenv("OPENPYPE_HEADLESS_MODE") == "1":
|
||||
_print("!!! Cannot open Igniter dialog in headless mode.")
|
||||
_print(
|
||||
"!!! Please use `OPENPYPE_MONGO` to specify server address.")
|
||||
_print("!!! Cannot open Igniter dialog in headless mode.", True)
|
||||
_print(("!!! Please use `OPENPYPE_MONGO` to specify "
|
||||
"server address."), True)
|
||||
sys.exit(1)
|
||||
_print("--- launching setup UI ...")
|
||||
|
||||
|
|
@ -783,7 +783,7 @@ def _find_frozen_openpype(use_version: str = None,
|
|||
try:
|
||||
version_path = bootstrap.extract_openpype(openpype_version)
|
||||
except OSError as e:
|
||||
_print("!!! failed: {}".format(str(e)))
|
||||
_print("!!! failed: {}".format(str(e)), True)
|
||||
sys.exit(1)
|
||||
else:
|
||||
# cleanup zip after extraction
|
||||
|
|
@ -899,7 +899,7 @@ def _boot_validate_versions(use_version, local_version):
|
|||
v: OpenPypeVersion
|
||||
found = [v for v in openpype_versions if str(v) == use_version]
|
||||
if not found:
|
||||
_print(f"!!! Version [ {use_version} ] not found.")
|
||||
_print(f"!!! Version [ {use_version} ] not found.", True)
|
||||
list_versions(openpype_versions, local_version)
|
||||
sys.exit(1)
|
||||
|
||||
|
|
@ -908,7 +908,8 @@ def _boot_validate_versions(use_version, local_version):
|
|||
use_version, openpype_versions
|
||||
)
|
||||
valid, message = bootstrap.validate_openpype_version(version_path)
|
||||
_print(f'{">>> " if valid else "!!! "}{message}')
|
||||
_print(f'{">>> " if valid else "!!! "}{message}', not valid)
|
||||
return valid
|
||||
|
||||
|
||||
def _boot_print_versions(openpype_root):
|
||||
|
|
@ -935,7 +936,7 @@ def _boot_print_versions(openpype_root):
|
|||
|
||||
|
||||
def _boot_handle_missing_version(local_version, message):
|
||||
_print(message)
|
||||
_print(message, True)
|
||||
if os.environ.get("OPENPYPE_HEADLESS_MODE") == "1":
|
||||
openpype_versions = bootstrap.find_openpype(
|
||||
include_zips=True)
|
||||
|
|
@ -983,7 +984,7 @@ def boot():
|
|||
openpype_mongo = _determine_mongodb()
|
||||
except RuntimeError as e:
|
||||
# without mongodb url we are done for.
|
||||
_print(f"!!! {e}")
|
||||
_print(f"!!! {e}", True)
|
||||
sys.exit(1)
|
||||
|
||||
os.environ["OPENPYPE_MONGO"] = openpype_mongo
|
||||
|
|
@ -1024,8 +1025,8 @@ def boot():
|
|||
local_version = OpenPypeVersion.get_installed_version_str()
|
||||
|
||||
if "validate" in commands:
|
||||
_boot_validate_versions(use_version, local_version)
|
||||
sys.exit(1)
|
||||
valid = _boot_validate_versions(use_version, local_version)
|
||||
sys.exit(1 if not valid else 0)
|
||||
|
||||
if not openpype_path:
|
||||
_print("*** Cannot get OpenPype path from database.")
|
||||
|
|
@ -1035,7 +1036,7 @@ def boot():
|
|||
|
||||
if "print_versions" in commands:
|
||||
_boot_print_versions(OPENPYPE_ROOT)
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
||||
# ------------------------------------------------------------------------
|
||||
# Find OpenPype versions
|
||||
|
|
@ -1052,13 +1053,13 @@ def boot():
|
|||
|
||||
except RuntimeError as e:
|
||||
# no version to run
|
||||
_print(f"!!! {e}")
|
||||
_print(f"!!! {e}", True)
|
||||
sys.exit(1)
|
||||
# validate version
|
||||
_print(f">>> Validating version [ {str(version_path)} ]")
|
||||
result = bootstrap.validate_openpype_version(version_path)
|
||||
if not result[0]:
|
||||
_print(f"!!! Invalid version: {result[1]}")
|
||||
_print(f"!!! Invalid version: {result[1]}", True)
|
||||
sys.exit(1)
|
||||
_print("--- version is valid")
|
||||
else:
|
||||
|
|
@ -1126,7 +1127,7 @@ def boot():
|
|||
cli.main(obj={}, prog_name="openpype")
|
||||
except Exception: # noqa
|
||||
exc_info = sys.exc_info()
|
||||
_print("!!! OpenPype crashed:")
|
||||
_print("!!! OpenPype crashed:", True)
|
||||
traceback.print_exception(*exc_info)
|
||||
sys.exit(1)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue