diff --git a/start.py b/start.py index 0d4addf59f..05069862bf 100644 --- a/start.py +++ b/start.py @@ -124,7 +124,10 @@ else: import igniter # noqa: E402 from igniter import BootstrapRepos # noqa: E402 -from igniter.tools import get_openpype_path_from_db # noqa +from igniter.tools import ( + get_openpype_path_from_db, + validate_mongo_connection +) # noqa from igniter.bootstrap_repos import OpenPypeVersion # noqa: E402 bootstrap = BootstrapRepos() @@ -306,20 +309,32 @@ def _determine_mongodb() -> str: openpype_mongo = os.getenv("OPENPYPE_MONGO", None) if not openpype_mongo: # try system keyring + try: + openpype_mongo = bootstrap.secure_registry.get_item( + "openPypeMongo" + ) + except ValueError: + pass + + if openpype_mongo: + result, msg = validate_mongo_connection(openpype_mongo) + if not result: + print(msg) + openpype_mongo = None + + if not openpype_mongo: + print("*** No DB connection string specified.") + print("--- launching setup UI ...") + + result = igniter.open_dialog() + if result == 0: + raise RuntimeError("MongoDB URL was not defined") + try: openpype_mongo = bootstrap.secure_registry.get_item( "openPypeMongo") except ValueError: - print("*** No DB connection string specified.") - print("--- launching setup UI ...") - import igniter - igniter.open_dialog() - - try: - openpype_mongo = bootstrap.secure_registry.get_item( - "openPypeMongo") - except ValueError: - raise RuntimeError("missing mongodb url") + raise RuntimeError("Missing MongoDB url") return openpype_mongo