Skip to content

Commit

Permalink
Merge pull request #2 from ynput/enhancement/AY-4970_Move-changes_vie…
Browse files Browse the repository at this point in the history
…wer-out-of-Unreal-before-launching

Moves Sync dialog outside of Unreal
  • Loading branch information
antirotor authored Aug 7, 2024
2 parents 91e07fa + ad07f3e commit 0cb42f2
Show file tree
Hide file tree
Showing 27 changed files with 341 additions and 1,222 deletions.
2 changes: 2 additions & 0 deletions client/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[tool.poetry.dependencies]
python = "^3.9"

[ayon.runtimeDependencies]
p4python = "^2023.1.2454917"
61 changes: 0 additions & 61 deletions client/version_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,10 @@
Package for interfacing with version control systems
"""

_compatible_dcc = True

import six

from .addon import VERSION_CONTROL_ADDON_DIR
from .addon import VersionControlAddon

if six.PY3:
# This is a clever hack to get python to import in a lazy (sensible) way
# whilst allowing static analysis to work correctly.
# Effectively this is forcing python to see these sub-packages without
# importing any packages until they are needed, this also helps
# avoid triggering potential dependency loops.
# The module level __getattr__ will handle lazy imports in this syntax:

# ```
# import version_control
# version_control.backends.perforce.sync
# ```

import importlib
import pathlib

# this is used instead of typing.TYPE_CHECKING as it
# avoids needing to import the typing module at all:
_typing = False
if _typing:
from typing import Any

from . import api
from . import backends
from . import hosts
from . import lib
from . import widgets
del _typing

def __getattr__(name):
# type: (str) -> Any
current_file = pathlib.Path(__file__)
current_directory = current_file.parent
for path in current_directory.iterdir():
if path.stem != name:
continue

try:
return importlib.import_module("{0}.{1}".format(__package__, name))
except ImportError as error:
if "No module named P4API" not in str(error):
raise

global _compatible_dcc
_compatible_dcc = False

raise AttributeError("{0} has no attribute named: {0}".format(__package__, name))

else:
raise RuntimeError("Version control is not supported on Python2")

__all__ = (
"api",
"backends",
"hosts",
"lib",
"widgets",
"VersionControlAddon",
"VERSION_CONTROL_ADDON_DIR",
"_compatible_dcc"
)
37 changes: 24 additions & 13 deletions client/version_control/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
class VersionControlAddon(AYONAddon, ITrayService, IPluginPaths):
# _icon_name = "mdi.jira"
# _icon_scale = 1.3
webserver = None
active_version_control_system = None

# Properties:
@property
Expand All @@ -34,7 +36,7 @@ def initialize(self, settings):
assert self.name in settings, (
"{} not found in settings - make sure they are defined in the defaults".format(self.name)
)
vc_settings = settings[self.name] # type: dict[str, Any]
vc_settings = settings[self.name] # type: dict[str, Any]
enabled = vc_settings["enabled"] # type: bool
active_version_control_system = vc_settings["active_version_control_system"] # type: str
self.active_version_control_system = active_version_control_system
Expand All @@ -60,17 +62,16 @@ def get_connection_info(self, project_name, project_settings=None):
if workspace_dir:
workspace_dir = os.path.normpath(workspace_dir)

conn_info = {}
conn_info["host"] = version_settings["host_name"]
conn_info["port"] = version_settings["port"]
conn_info["username"] = local_setting["username"]
conn_info["password"] = local_setting["password"]
conn_info["workspace_dir"] = workspace_dir

return conn_info
return {
"host": version_settings["host_name"],
"port": version_settings["port"],
"username": local_setting["username"],
"password": local_setting["password"],
"workspace_dir": workspace_dir
}

def sync_to_latest(self, conn_info):
from version_control.backends.perforce.api.rest_stub import \
from version_control.rest.perforce.rest_stub import \
PerforceRestStub

PerforceRestStub.login(host=conn_info["host"],
Expand All @@ -82,7 +83,7 @@ def sync_to_latest(self, conn_info):
return

def sync_to_version(self, conn_info, change_id):
from version_control.backends.perforce.api.rest_stub import \
from version_control.rest.perforce.rest_stub import \
PerforceRestStub

PerforceRestStub.login(host=conn_info["host"],
Expand All @@ -96,15 +97,15 @@ def sync_to_version(self, conn_info, change_id):

def tray_exit(self):
if self.enabled and \
self.webserver and self.webserver.server_is_running():
self.webserver and self.webserver.server_is_running:
self.webserver.stop()

def tray_init(self):
return

def tray_start(self):
if self.enabled:
from .backends.perforce.communication_server import WebServer
from version_control.rest.communication_server import WebServer
self.webserver = WebServer()
self.webserver.start()

Expand All @@ -123,6 +124,16 @@ def get_publish_plugin_paths(self, host_name):
return [os.path.join(VERSION_CONTROL_ADDON_DIR,
"plugins", "publish")]

def get_launch_hook_paths(self, _app):
"""Implementation for applications launch hooks.
Returns:
(str): full absolute path to directory with hooks for the module
"""

return os.path.join(VERSION_CONTROL_ADDON_DIR, "launch_hooks",
self.active_version_control_system)


@click.group("version_control", help="Version Control module related commands.")
def cli_main():
Expand Down
Loading

0 comments on commit 0cb42f2

Please sign in to comment.