mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
modified get_pype_path_from_db to use get_pype_global_settings function
This commit is contained in:
parent
e7781a4540
commit
b98fd5d0a9
1 changed files with 2 additions and 29 deletions
|
|
@ -224,40 +224,13 @@ def get_pype_global_settings(url: str) -> dict:
|
|||
|
||||
|
||||
def get_pype_path_from_db(url: str) -> Union[str, None]:
|
||||
"""Get Pype path from database.
|
||||
|
||||
We are loading data from database `pype` and collection `settings`.
|
||||
There we expect document type `global_settings`.
|
||||
"""Get Pype path from global settings.
|
||||
|
||||
Args:
|
||||
url (str): mongodb url.
|
||||
|
||||
Returns:
|
||||
path to Pype or None if not found
|
||||
|
||||
"""
|
||||
try:
|
||||
components = decompose_url(url)
|
||||
except RuntimeError:
|
||||
return None
|
||||
mongo_args = {
|
||||
"host": compose_url(**components),
|
||||
"serverSelectionTimeoutMS": 2000
|
||||
}
|
||||
port = components.get("port")
|
||||
if port is not None:
|
||||
mongo_args["port"] = int(port)
|
||||
|
||||
try:
|
||||
client = MongoClient(**mongo_args)
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
db = client.pype
|
||||
col = db.settings
|
||||
|
||||
global_settings = col.find_one({"type": "global_settings"}, {"data": 1})
|
||||
if not global_settings:
|
||||
return None
|
||||
global_settings.get("data", {})
|
||||
global_settings = get_pype_global_settings(url)
|
||||
return global_settings.get("pype_path", {}).get(platform.system().lower())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue