Skip to content

Commit

Permalink
Merge pull request #147 from masqu3rad3/TIK-140-shotgrid-integration
Browse files Browse the repository at this point in the history
Tik 140 shotgrid integration
  • Loading branch information
masqu3rad3 authored Dec 4, 2024
2 parents ce8f30a + 677914a commit 2b07b8d
Show file tree
Hide file tree
Showing 758 changed files with 136,773 additions and 784 deletions.
16 changes: 13 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Configuration file for the Sphinx documentation builder.

import os
import sys

# Add the path to the tik_manager4 folder to sys.path
sys.path.insert(0, os.path.abspath('../../tik_manager4/'))

# Import the version from _version.py
from _version import __version__

# -- Project information

project = 'Tik Manager4'
copyright = '2023, Arda Kutlu'
author = 'Arda Kutlu'

release = '0.1'
version = '4.0.2'
# Automatically populate version and release from _version.py
version = __version__ # Short X.Y version
release = __version__ # Full version including alpha/beta/rc tags

# -- General configuration

Expand All @@ -23,7 +33,7 @@

autoapi_dirs = ['../../tik_manager4/']
autoapi_type = 'python'
autoapi_ignore = ['*setup*', '*shiboken*', '*PySide2*', '*PySide6*', '*PyQt5*', '*PyQt6*']
autoapi_ignore = ['*setup*', '*shiboken*', '*PySide2*', '*PySide6*', '*PyQt5*', '*PyQt6*', '*external/**/*']
autoapi_file_patterns = ['*.py']
add_module_names = False
autoapi_member_order = 'groupwise'
Expand Down
2 changes: 1 addition & 1 deletion package/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

REM Set the QT_PREFERRED_BINDING_JSON environment variable to '{"tik_manager4.ui.Qt": ["PyQt5"], "default":["PyQt5"]}'
REM This will force the use of PyQt5 for the Qt binding
set "QT_PREFERRED_BINDING_JSON={"tik_manager4.ui.Qt": ["PyQt5"], "default":["PyQt5"]}"
set "QT_PREFERRED_BINDING_JSON={"tik_manager4.ui.Qt": ["PySide2"], "default":["PySide2"]}"


REM This batch file will execute release_package.py with specified arguments.
Expand Down
3 changes: 2 additions & 1 deletion package/release_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ def inno_setup(self):
_debug_mode = any([opt in ("-d", "--debug") for opt, _ in opts])
release_utility = ReleaseUtility(debug_mode=_debug_mode)
release_utility.freeze()
release_utility.inno_setup()
if not _debug_mode:
release_utility.inno_setup()
2 changes: 1 addition & 1 deletion package/tik_manager4_innosetup.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define appName "Tik Manager4"
#define appVersion "4.2.1"
#define appVersion "4.3.0"

[Setup]
AppId={{0BAFF3AF-5D10-4CA9-9232-428F16D17175}
Expand Down
2 changes: 1 addition & 1 deletion package/tik_manager4_innosetup_debug.iss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define appName "Tik Manager4"
#define appVersion "4.2.0-beta"
#define appVersion "4.2.1"

[Setup]
AppId={{0BAFF3AF-5D10-4CA9-9232-428F16D17175}
Expand Down
2 changes: 1 addition & 1 deletion tests/maya/test_maya_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_create_a_work(self, project, category="Model"):
assert work_obj.task_name == "test_task"
assert work_obj.task_id == test_task.id
assert work_obj.path == f"test_subproject/test_task/{category}/maya"
assert work_obj.state == "working"
assert work_obj.state == "active"

# iterate a version with .ma format
work_obj = test_task.categories[category].create_work("test_cube", file_format=".ma", notes="Same cube. Only ma format.")
Expand Down
11 changes: 5 additions & 6 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def test_edit_task(self, project_manual_path, tik):
task.edit(
name="Aquaman",
categories=["Model", "Rig", "LookDev", "Animation"],
task_type="Shot",
metadata_overrides={"mode": "shot"},
)
== -1
)
Expand All @@ -473,7 +473,7 @@ def test_edit_task(self, project_manual_path, tik):
task.edit(
name="Wonderboy",
categories=["Model", "Rig", "LookDev", "Animation"],
task_type="Shot",
metadata_overrides={"mode": "shot"},
)
== -1
)
Expand All @@ -484,25 +484,24 @@ def test_edit_task(self, project_manual_path, tik):

# wrong category type
with pytest.raises(Exception):
task.edit(name="Aquaman", categories="ThisIsWrong", task_type="Shot")
task.edit(name="Aquaman", categories="ThisIsWrong", metadata_overrides={"mode": "shot"})
# category not defined
with pytest.raises(Exception):
task.edit(
name="Aquaman",
categories=["Model", "Rig", "LookDev", "Animation", "ThisIsWrong"],
task_type="Shot",
metadata_overrides={"mode": "shot"},
)

# edit the task
task.edit(
name="Aquaman",
categories=["Model", "Rig", "LookDev", "Animation"],
task_type="Shot",
metadata_overrides={"mode": "shot"},
)

assert list(task.categories.keys()) == ["Model", "Rig", "LookDev", "Animation"]
assert task.name == "Aquaman"
assert task.type == "Shot"

def test_adding_categories(self, project_manual_path, tik):
self.test_creating_and_adding_new_tasks(project_manual_path, tik)
Expand Down
9 changes: 8 additions & 1 deletion tik_manager4/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import os
from pathlib import Path
from importlib import reload
from tik_manager4.objects import guard

def initialize(dcc_name, common_folder=None):
os.environ["TIK_DCC"] = dcc_name
parent_folder = Path(__file__).parent.parent / "tik_manager4" / "external"
os.environ["TIK_EXTERNAL_SOURCES"] = parent_folder.as_posix()
guard.Guard.set_dcc(dcc_name) # force the guard to use the dcc name
# the reload is necessary to make sure the dcc is reloaded
# this makes sure when different dcc's are used in the same python session
# for example, Maya and trigger.
import tik_manager4.objects.main
reload(tik_manager4.objects.main)
return tik_manager4.objects.main.Main(common_folder=common_folder)
return tik_manager4.objects.main.Main(common_folder=common_folder)

# get the installation folder of tik_manager4
# this is necessary to get the default settings
# and other resources
2 changes: 1 addition & 1 deletion tik_manager4/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version_info__ = ('4', '2', '1')
__version_info__ = ('4', '3', '0')
__version__ = '.'.join(__version_info__)
2 changes: 1 addition & 1 deletion tik_manager4/core/filelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def error(self, msg, proceed=True):
"""
stamped_msg = "%sERROR : %s" % (self._get_now(), msg)
self._start_logging()
self.logger.error(stamped_msg)
self.logger.error(stamped_msg, exc_info=True)
self.__set_last_message(msg, "error")
self._end_logging()
if not proceed:
Expand Down
6 changes: 6 additions & 0 deletions tik_manager4/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ def update(self, data, add_missing_keys=False):
else:
self._current_value.update(data)

def add_missing_keys(self, data):
"""Add only the non-existing keys, but do not update the existing ones."""
for key in data:
if key not in self._current_value:
self._current_value[key] = data[key]

def is_settings_changed(self):
"""Check if the settings changed since initialization."""
return not self._current_value == self._original_value
Expand Down
26 changes: 26 additions & 0 deletions tik_manager4/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
from pathlib import Path
import platform
import subprocess
import re
import unicodedata

CURRENT_PLATFORM = platform.system()


def get_home_dir():
"""Get the user home directory."""
# expanduser does not always return the same result (in Maya it returns user/Documents).
Expand All @@ -14,6 +18,7 @@ def get_home_dir():
return os.path.normpath(os.getenv("USERPROFILE"))
return os.path.normpath(os.getenv("HOME"))


def apply_stylesheet(file_path, widget):
"""Read and apply the qss file to the given widget.
Expand All @@ -31,6 +36,7 @@ def apply_stylesheet(file_path, widget):
return True
return False


def execute(file_path, executable=None):
"""Execute a file.
Expand All @@ -54,3 +60,23 @@ def execute(file_path, executable=None):
subprocess.Popen(["xdg-open", file_path])
else:
subprocess.Popen(["open", file_path])

def sanitize_text(text, allow_spaces=False):
"""
Sanitizes the given text by removing localized characters, replacing spaces
with underscores, and removing or replacing illegal characters based on the pattern.
"""

# Normalize and remove special/localized characters
text = unicodedata.normalize("NFKD", text)
text = "".join(c if unicodedata.category(c) != "Mn" else "" for c in text)

# Replace spaces with underscores if spaces are not allowed
if not allow_spaces:
text = text.replace(" ", "_")

# Define pattern to match allowed characters and remove illegal ones
pattern = r"[^A-Za-z0-9A_-]"
sanitized_text = re.sub(pattern, "", text)

return sanitized_text
2 changes: 1 addition & 1 deletion tik_manager4/dcc/blender/setup/tik_4_init_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

tik_path = "PATH\\TO\\PARENT\\FOLDER\\OF\\TIKMANAGER4\\"

pyside_path = str(Path(tik_path, "tik_manager4\\dcc\\blender\\site-packages"))
pyside_path = str(Path(tik_path, "tik_manager4\\external\\site-packages"))

if pyside_path not in sys.path:
sys.path.insert(0, pyside_path)
Expand Down
14 changes: 12 additions & 2 deletions tik_manager4/dcc/max/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ def get_current_camera():
else:
return "persp", ""

@staticmethod
def generate_preview(name, folder, camera_code, resolution, range, settings=None):
def generate_preview(self, name, folder, camera_code, resolution, range, settings=None):
"""
Create a preview from the current scene
Args:
Expand Down Expand Up @@ -215,6 +214,12 @@ def generate_preview(name, folder, camera_code, resolution, range, settings=None

extension = "avi"

# get current range
original_range = self.get_ranges()

# temporarily set the range
self.set_ranges(range)

# get the current values
original_values = {
"width": rt.renderWidth,
Expand Down Expand Up @@ -259,8 +264,13 @@ def generate_preview(name, folder, camera_code, resolution, range, settings=None
dspFrameNums=display_frame_nums,
rndLevel=render_level,
autoPlay=not settings["PostConversion"],
start=range[0],
end=range[-1]
)

# restore the original range
self.set_ranges(original_range)

# restore the original values
rt.renderWidth = original_values["width"]
rt.renderHeight = original_values["height"]
Expand Down
2 changes: 1 addition & 1 deletion tik_manager4/dcc/maya/extract/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def _extract_default(self):
pb_panel.hud = display_huds

cmds.select(camera)
nice_name = camera.split("|")[-1]
nice_name = camera.split("|")[-1].replace(":", "_")
file_path_without_extension = bundle_directory / f"{nice_name}"
cmds.playblast(
format="image",
Expand Down
4 changes: 4 additions & 0 deletions tik_manager4/dcc/maya/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ def generate_preview(name, folder, camera_code, resolution, range, settings=None
startTime=range[0],
endTime=range[1],
)
if not _output:
LOG.error("Playblast failed")
pb_panel.kill()
return None

final_clip = f"{_output}.{extension}"
pb_panel.kill()
Expand Down
81 changes: 0 additions & 81 deletions tik_manager4/dcc/photoshop/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,84 +65,6 @@ def get_photoshop_registry_keys(prefix):
pass
return keys

# @staticmethod
# def get_photoshop_registry_keys():
# photoshop_keys = []
# try:
# # Open the registry key
# key = winreg.OpenKey(winreg.HKEY_CLASSES_ROOT, "Photoshop.Application")
#
# # Enumerate all subkeys
# index = 0
# while True:
# try:
# subkey = winreg.EnumKey(key, index)
# if subkey.startswith("Photoshop.Application"):
# photoshop_keys.append(subkey)
# index += 1
# except OSError:
# break
#
# # Close the registry key
# winreg.CloseKey(key)
#
# except Exception as e:
# print(f"Error accessing registry: {e}")
#
# return photoshop_keys

# def getPhotoshopDispatchName(self, excludes=None):
# """Get the name of the Photoshop dispatch object."""
#
# name = "Photoshop.Application"
# classBase = "SOFTWARE\\Classes\\"
# try:
# if excludes and name in excludes:
# raise Exception()
#
# winreg.OpenKey(
# winreg.HKEY_LOCAL_MACHINE,
# classBase + name,
# 0,
# winreg.KEY_READ | winreg.KEY_WOW64_64KEY,
# )
# except:
# classKey = winreg.OpenKey(
# winreg.HKEY_LOCAL_MACHINE,
# classBase,
# 0,
# winreg.KEY_READ | winreg.KEY_WOW64_64KEY,
# )
# try:
# i = 0
# keyName = None
# while True:
# classNameKey = winreg.EnumKey(classKey, i)
# if excludes and classNameKey in excludes:
# i += 1
# continue
#
# if classNameKey.startswith("Photoshop.Application."):
# if keyName:
# try:
# if float(classNameKey.replace("Photoshop.Application.", "")) > float(keyName.replace("Photoshop.Application.", "")):
# keyName = classNameKey
# except:
# pass
# else:
# keyName = classNameKey
#
# elif keyName:
# return keyName
#
# i += 1
# except WindowsError:
# pass
#
# else:
# return name


def save_as(self, file_path):
"""Save the current scene as a new file.
Expand Down Expand Up @@ -177,9 +99,6 @@ def open(self, file_path, force=True, **extra_arguments):
Args:
file_path (str): Path to the file to load.
"""
# import pdb
# pdb.set_trace()
print("file_path: ", file_path)
self.com_link.Open(file_path)

def get_scene_file(self):
Expand Down
2 changes: 2 additions & 0 deletions tik_manager4/defaults/management_settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
}
Loading

0 comments on commit 2b07b8d

Please sign in to comment.