Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup unnecessary multiple version system abstraction #2

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5f1284a
Renamed folder
kalisp Feb 6, 2025
8f10a62
Replaced renamed folder in imports
kalisp Feb 6, 2025
06be5a8
REmoved undefined.py
kalisp Feb 6, 2025
0a1608b
Renamed key for storing metadata
kalisp Feb 6, 2025
02da99c
Simplified hooks location
kalisp Feb 6, 2025
0b21af6
Updated package descriptors
kalisp Feb 6, 2025
9292c7a
Renamed name of addon in controller
kalisp Feb 6, 2025
ebc0abe
Removed obsolete Python2 support
kalisp Feb 6, 2025
65b45ac
Renamed is_version_control_enabled
kalisp Feb 6, 2025
baed65e
Merged abstract and backend classes
kalisp Feb 6, 2025
f02422e
Simplified backends structure to single backend
kalisp Feb 6, 2025
e60e08b
Renamed is_version_control_enabled
kalisp Feb 6, 2025
26ef729
Removed unneeded p4_offline.py
kalisp Feb 6, 2025
38b0d98
Removed unneeded p4_dcc.py
kalisp Feb 6, 2025
9f44760
Removed unnecessary inheritance
kalisp Feb 7, 2025
8ef63c3
Removed unused functions
kalisp Feb 7, 2025
ab6d23d
Updated typing definitions
kalisp Feb 7, 2025
80b2d00
Removed unused functions
kalisp Feb 7, 2025
518c393
Clean up imports
kalisp Feb 7, 2025
940bcce
Removed unused signallers and offline mode
kalisp Feb 7, 2025
65f6d99
Formatting changes
kalisp Feb 7, 2025
d0eb821
Updated Settings to be more perforce labeled
kalisp Feb 11, 2025
8228d8a
Removed active_version_control_system
kalisp Feb 11, 2025
24bee9c
Fixed Settings initialization check
kalisp Feb 11, 2025
3298219
Fix obsolete imports
kalisp Feb 11, 2025
37efae8
Fix settings retrieval
kalisp Feb 11, 2025
bd64199
Updated typing
kalisp Feb 11, 2025
01f9686
Formatting changes
kalisp Feb 11, 2025
98801ca
Renaming function, formatting
kalisp Feb 11, 2025
f4e976a
Updated credentials collector
kalisp Feb 11, 2025
43233f4
Refactored names
kalisp Feb 11, 2025
427b080
Fix profile in Settings
kalisp Feb 11, 2025
426c4b4
Fix querying profiles
kalisp Feb 11, 2025
22623b8
Fix initialization if addon disabled
kalisp Feb 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions client/ayon_perforce/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Package for interfacing with version control systems
"""
from .addon import (
PerforceAddon,
is_perforce_enabled,
PERFORCE_ADDON_DIR
)

__all__ = (
"PerforceAddon",
"is_perforce_enabled",
"PERFORCE_ADDON_DIR",
)
71 changes: 30 additions & 41 deletions client/version_control/addon.py → client/ayon_perforce/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,35 @@
from .lib import WorkspaceProfileContext


VERSION_CONTROL_ADDON_DIR = os.path.dirname(os.path.abspath(__file__))
PERFORCE_ADDON_DIR = os.path.dirname(os.path.abspath(__file__))


class VersionControlAddon(AYONAddon, ITrayService, IPluginPaths):
class PerforceAddon(AYONAddon, ITrayService, IPluginPaths):

label = "Version Control"
name = "version_control"
label = "Perforce"
name = "ayon_perforce"
version = __version__

# _icon_name = "mdi.jira"
# _icon_scale = 1.3
webserver = None
active_version_control_system = None

# Properties:
@property
def name(self):
# type: () -> str
return "version_control"
def name(self) -> str:
return "perforce"

@property
def label(self):
# type: () -> str
return f"Version Control: {self.active_version_control_system.title()}"
def label(self) -> str:
return f"Perforce Version Control"

# Public Methods:
def initialize(self, settings):
# type: (dict[str, Any]) -> None
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]
active_version_control_system = vc_settings["active_version_control_system"] # type: str
self.active_version_control_system = active_version_control_system
enabled = vc_settings["enabled"] # type: bool
def initialize(self, settings: dict[str, Any]):
vc_settings = settings.get(self.name) # type: dict[str, Any]
enabled = vc_settings and vc_settings["enabled"] # type: bool
self.set_service_running_icon() if enabled else self.set_service_failed_icon()

def get_global_environments(self):
# return {"ACTIVE_VERSION_CONTROL_SYSTEM": self.active_version_control_system}
return {}

def get_connection_info(
Expand All @@ -64,8 +54,8 @@ def get_connection_info(
if not project_settings:
project_settings = get_project_settings(project_name)

version_settings = project_settings["version_control"]
local_setting = version_settings["local_setting"]
settings = project_settings["perforce"]
local_setting = settings["local_setting"]

workspace_name = None
filtering_criteria = {
Expand All @@ -88,22 +78,23 @@ def get_connection_info(
workspace_name = profile["workspace_name"]

return {
"host": version_settings["host_name"],
"port": version_settings["port"],
"host": settings["host_name"],
"port": settings["port"],
"username": local_setting["username"],
"password": local_setting["password"],
"workspace_name": workspace_name
}

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

PerforceRestStub.login(host=conn_info["host"],
port=conn_info["port"],
username=conn_info["username"],
password=conn_info["password"],
workspace=conn_info["workspace_dir"])
from ayon_perforce.rest.perforce.rest_stub import PerforceRestStub

PerforceRestStub.login(
host=conn_info["host"],
port=conn_info["port"],
username=conn_info["username"],
password=conn_info["password"],
workspace=conn_info["workspace_dir"]
)
PerforceRestStub.sync_to_version(
f"{conn_info['workspace_dir']}/...", change_id)
return
Expand All @@ -118,7 +109,7 @@ def tray_init(self):

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

Expand All @@ -128,11 +119,10 @@ def get_plugin_paths(self):
def get_create_plugin_paths(self, host_name):
if host_name != "unreal":
return []
return ["{}/plugins/create/unreal".format(VERSION_CONTROL_ADDON_DIR)]
return ["{}/plugins/create/unreal".format(PERFORCE_ADDON_DIR)]

def get_publish_plugin_paths(self, host_name):
return [os.path.join(VERSION_CONTROL_ADDON_DIR,
"plugins", "publish")]
return [os.path.join(PERFORCE_ADDON_DIR, "plugins", "publish")]

def get_launch_hook_paths(self, _app):
"""Implementation for applications launch hooks.
Expand All @@ -141,9 +131,8 @@ def get_launch_hook_paths(self, _app):
(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)
return os.path.join(PERFORCE_ADDON_DIR, "launch_hooks")


def is_version_control_enabled(project_settings):
return project_settings.get("version_control", {}).get("enabled", False)
def is_perforce_enabled(project_settings):
return project_settings.get("perforce", {}).get("enabled", False)
Loading