mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Global: custom location for OP local versions (#4673)
* OP-5221 - updated settings for custom location of artist zip folder * OP-5221 - updated igniter for custom location of artist zip folder Introduced new function Updated data_dir only after access to Mongo (DB) * OP-5221 - pushed resolving of local folder to OpenPypeVersion Logic in OpenPypeVersion is used even in openpype_version.py * OP-5221 - updates after review * OP-5221 - fix paths should be single paths * OP-5221 - refactor to cls * OP-5221 - refactor Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * OP-5221 - fix defaults for single paths Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * OP-5221 - remove unwanted line Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> * OP-5221 - update look of Settings Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
This commit is contained in:
parent
66c4522f9c
commit
e42aebc1f2
8 changed files with 97 additions and 11 deletions
|
|
@ -25,7 +25,8 @@ from .user_settings import (
|
|||
from .tools import (
|
||||
get_openpype_global_settings,
|
||||
get_openpype_path_from_settings,
|
||||
get_expected_studio_version_str
|
||||
get_expected_studio_version_str,
|
||||
get_local_openpype_path_from_settings
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -61,6 +62,8 @@ class OpenPypeVersion(semver.VersionInfo):
|
|||
|
||||
"""
|
||||
path = None
|
||||
|
||||
_local_openpype_path = None
|
||||
# this should match any string complying with https://semver.org/
|
||||
_VERSION_REGEX = re.compile(r"(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>[a-zA-Z\d\-.]*))?(?:\+(?P<buildmetadata>[a-zA-Z\d\-.]*))?") # noqa: E501
|
||||
_installed_version = None
|
||||
|
|
@ -289,6 +292,23 @@ class OpenPypeVersion(semver.VersionInfo):
|
|||
"""
|
||||
return os.getenv("OPENPYPE_PATH")
|
||||
|
||||
@classmethod
|
||||
def get_local_openpype_path(cls):
|
||||
"""Path to unzipped versions.
|
||||
|
||||
By default it should be user appdata, but could be overridden by
|
||||
settings.
|
||||
"""
|
||||
if cls._local_openpype_path:
|
||||
return cls._local_openpype_path
|
||||
|
||||
settings = get_openpype_global_settings(os.environ["OPENPYPE_MONGO"])
|
||||
data_dir = get_local_openpype_path_from_settings(settings)
|
||||
if not data_dir:
|
||||
data_dir = Path(user_data_dir("openpype", "pypeclub"))
|
||||
cls._local_openpype_path = data_dir
|
||||
return data_dir
|
||||
|
||||
@classmethod
|
||||
def openpype_path_is_set(cls):
|
||||
"""Path to OpenPype zip directory is set."""
|
||||
|
|
@ -319,9 +339,8 @@ class OpenPypeVersion(semver.VersionInfo):
|
|||
list: of compatible versions available on the machine.
|
||||
|
||||
"""
|
||||
# DEPRECATED: backwards compatible way to look for versions in root
|
||||
dir_to_search = Path(user_data_dir("openpype", "pypeclub"))
|
||||
versions = OpenPypeVersion.get_versions_from_directory(dir_to_search)
|
||||
dir_to_search = cls.get_local_openpype_path()
|
||||
versions = cls.get_versions_from_directory(dir_to_search)
|
||||
|
||||
return list(sorted(set(versions)))
|
||||
|
||||
|
|
@ -533,17 +552,15 @@ class BootstrapRepos:
|
|||
|
||||
"""
|
||||
# vendor and app used to construct user data dir
|
||||
self._vendor = "pypeclub"
|
||||
self._app = "openpype"
|
||||
self._message = message
|
||||
self._log = log.getLogger(str(__class__))
|
||||
self.data_dir = Path(user_data_dir(self._app, self._vendor))
|
||||
self.set_data_dir(None)
|
||||
self.secure_registry = OpenPypeSecureRegistry("mongodb")
|
||||
self.registry = OpenPypeSettingsRegistry()
|
||||
self.zip_filter = [".pyc", "__pycache__"]
|
||||
self.openpype_filter = [
|
||||
"openpype", "schema", "LICENSE"
|
||||
]
|
||||
self._message = message
|
||||
|
||||
# dummy progress reporter
|
||||
def empty_progress(x: int):
|
||||
|
|
@ -554,6 +571,13 @@ class BootstrapRepos:
|
|||
progress_callback = empty_progress
|
||||
self._progress_callback = progress_callback
|
||||
|
||||
def set_data_dir(self, data_dir):
|
||||
if not data_dir:
|
||||
self.data_dir = Path(user_data_dir("openpype", "pypeclub"))
|
||||
else:
|
||||
self._print(f"overriding local folder: {data_dir}")
|
||||
self.data_dir = data_dir
|
||||
|
||||
@staticmethod
|
||||
def get_version_path_from_list(
|
||||
version: str, version_list: list) -> Union[Path, None]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue