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

Tik 145 native dcc support for snapshot saves #175

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions package/make.bat
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@ IF "%1"=="" (
REM Execute commands based on the argument
IF "%ARG%"=="release" (
python release_package.py
) ELSE IF "%ARG%"=="testrelease" (
python release_package.py --testrelease
) ELSE IF "%ARG%"=="debug" (
python release_package.py --debug
) ELSE IF "%ARG%"=="clean" (
12 changes: 10 additions & 2 deletions package/release_package.py
Original file line number Diff line number Diff line change
@@ -88,13 +88,21 @@ def extract_and_sanitize_release_notes(self):
LOG.info("Release notes extracted and saved to %s", output_file)
return output_file



if __name__ == "__main__":
# get the arguments from sys
opts, args = getopt.getopt(sys.argv[1:], "d", ["debug"])
opts, args = getopt.getopt(sys.argv[1:], ["d", "t"], ["debug", "testrelease"])
# if there is a debug flag, set the debug mode to True
_debug_mode = any([opt in ("-d", "--debug") for opt, _ in opts])
_testrelease_mode = any([opt in ("-t", "--testrelease") for opt, _ in opts])
release_utility = ReleaseUtility(debug_mode=_debug_mode)
if _debug_mode:
release_utility.release_version = f"{_version.__version__}-debug"
if _testrelease_mode:
release_utility.release_version = f"{_version.__version__}-alpha"
release_utility.freeze()
release_utility.extract_and_sanitize_release_notes()
if not _testrelease_mode or _debug_mode:
release_utility.extract_and_sanitize_release_notes()
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.3.0"
#define appVersion "4.3.0-alpha"

[Setup]
AppId={{0BAFF3AF-5D10-4CA9-9232-428F16D17175}
Binary file modified tik_manager4/dist/tik4/install_dccs.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_photoshop.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_ps_new_version.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_ps_publish.exe
Binary file not shown.
Binary file modified tik_manager4/dist/tik4/tik4_standalone.exe
Binary file not shown.
10 changes: 6 additions & 4 deletions tik_manager4/objects/category.py
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ def __add_work_properties(self, work, name, dcc, dcc_version, relative_path):
work.add_property("state", "active")
work.init_properties()

def create_work_from_path(self, name, file_path, notes="", ignore_checks=True):
def create_work_from_path(self, name, file_path, override_dcc="standalone", notes="", ignore_checks=True):
"""Register a given path (file or folder) as a work.

Args:
@@ -114,20 +114,22 @@ def create_work_from_path(self, name, file_path, notes="", ignore_checks=True):
Returns:
tik_manager4.objects.work: Work object.
"""
# import dcc
# print(dcc.EXTENSION_DICT)
_ignore_checks = ignore_checks
constructed_name = self.construct_name(name)
# creating work from an arbitrary path is always considered as a 'standalone' process
abs_path = self.get_abs_database_path("standalone", f"{constructed_name}.twork")
abs_path = self.get_abs_database_path(override_dcc, f"{constructed_name}.twork")
if Path(abs_path).exists():
# in that case instantiate the work and iterate the version.
work = Work(absolute_path=abs_path, parent_task=self.parent_task)
work.new_version_from_path(file_path=file_path, notes=notes)
return work

relative_path = self.get_relative_work_path(override_dcc="standalone")
relative_path = self.get_relative_work_path(override_dcc=override_dcc)
work = Work(abs_path, name=constructed_name, path=relative_path, parent_task=self.parent_task)

self.__add_work_properties(work, constructed_name, "standalone", "NA", relative_path)
self.__add_work_properties(work, constructed_name, override_dcc, "NA", relative_path)
work.new_version_from_path(file_path=file_path, notes=notes)
return work

5 changes: 3 additions & 2 deletions tik_manager4/objects/main.py
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ def __init__(self, common_folder=None):
self.project.guard.set_dcc_handler(self.dcc)
self.project.guard.set_commons(self.user.commons)
self.project.guard.set_localize_settings(self.user.localization)
self.all_dcc_extensions = dcc.EXTENSION_DICT


default_project = Path(utils.get_home_dir(), "TM4_default")
@@ -200,7 +201,7 @@ def collect_template_paths(self):
# if the dcc is standalone, collect all applicable extensions from the extension dictionary
# otherwise, collect the extensions from the dcc object
if self.dcc.name.lower() == "standalone":
extensions = [ext for ext_list in dcc.EXTENSION_DICT.values() for ext in ext_list]
extensions = [ext for ext_list in self.all_dcc_extensions.values() for ext in ext_list]
else:
extensions = self.dcc.formats
user_templates = [p for p in Path(self.user.settings.get("user_templates_directory")).rglob("*.*") if
@@ -245,7 +246,7 @@ def __resolve_dcc_name_from_extension(self, extension):
Returns:
str: The DCC name.
"""
for key, value in dcc.EXTENSION_DICT.items():
for key, value in self.all_dcc_extensions.items():
if extension in value:
return key
# for anything else, return standalone
62 changes: 0 additions & 62 deletions tik_manager4/objects/work.py
Original file line number Diff line number Diff line change
@@ -317,8 +317,6 @@ def new_version(self, file_format=None, notes="", ignore_checks=True):
"previews": {},
"file_format": file_format,
"dcc_version": self._dcc_handler.get_dcc_version(),
# "localized": is_localized,
# "localized_path": output_path if is_localized else "",
}
if is_localized:
version_dict["localized"] = is_localized
@@ -463,43 +461,9 @@ def destroy(self):

for version in self.versions:
version.move_to_purgatory()
#
# purgatory_database_dir = Path(self.get_purgatory_database_path())
# purgatory_database_dir.mkdir(parents=True, exist_ok=True)
# purgatory_scene_dir = Path(self.get_purgatory_project_path())
# purgatory_scene_dir.mkdir(parents=True, exist_ok=True)
#
# purgatory_path = self.get_purgatory_project_path(self.name)
# # if the purgatory path exists, delete it first
# if Path(purgatory_path).exists():
# shutil.rmtree(purgatory_path)
#
# for version in self.versions:
# shutil.move(
# version.get_resolved_path(),
# purgatory_path,
# copy_function=shutil.copytree,
# )
# # shutil.move(
# # # self.get_abs_project_path(self.name),
# # self.get_resolved_path(self.name),
# # purgatory_path,
# # copy_function=shutil.copytree,
# # )
#
# thumbnails_dir = Path(self.get_abs_database_path("thumbnails"))
# # collect all thumbnails starting with the work name
# thumbnails = thumbnails_dir.glob(f"{self.name}_*")
# for thumbnail in thumbnails:
# thumb_destination_dir = purgatory_database_dir / "thumbnails"
# thumb_destination_dir.mkdir(parents=True, exist_ok=True)
# thumb_destination_file = thumb_destination_dir / thumbnail.name
# shutil.move(str(thumbnail), str(thumb_destination_file))

# finally move the database file
# db_destination = purgatory_database_dir / Path(self.settings_file).name
db_destination = Path(self.get_resolved_purgatory_path(), self.settings_file.name)
# shutil.move(str(self.settings_file), str(db_destination))
utils.move(self.settings_file.as_posix(), db_destination.as_posix())
return 1, "success"

@@ -548,32 +512,6 @@ def delete_version(self, version_number):
version_obj = self.get_version(version_number)
if version_obj:
version_obj.move_to_purgatory()
# if version_obj:
# relative_path = version_obj.scene_path
# abs_path = version_obj.get_resolved_path()
# dest_path = self.get_purgatory_project_path(relative_path)
# Path(dest_path).parent.mkdir(parents=True, exist_ok=True)
# if Path(abs_path).exists():
# shutil.move(abs_path, dest_path)
#
# # move the thumbnail
# thumbnail_relative_path = version_obj.thumbnail
# if thumbnail_relative_path:
# thumbnail_abs_path = self.get_abs_database_path(thumbnail_relative_path)
# thumbnail_dest_path = self.get_purgatory_database_path(
# thumbnail_relative_path
# )
# _thumbnail_dest_path = Path(thumbnail_dest_path)
# _thumbnail_dest_path.parent.mkdir(parents=True, exist_ok=True)
# if Path(thumbnail_abs_path).exists():
# # first try to delete the thumbnail_dest_path if exists
# if _thumbnail_dest_path.exists():
# _thumbnail_dest_path.unlink()
# shutil.move(
# thumbnail_abs_path,
# thumbnail_dest_path,
# copy_function=shutil.copytree,
# )

# remove the version from the versions list
self._versions.remove(version_obj)
20 changes: 19 additions & 1 deletion tik_manager4/ui/dialog/work_dialog.py
Original file line number Diff line number Diff line change
@@ -516,21 +516,39 @@ def __init__(self, main_object, file_or_folder_path=None, *args, **kwargs):
def on_create_work(self):
"""Create the work file."""
name = self.primary_data.get_property("name")
override_dcc = self.primary_data.get_property("override_dcc")
notes = self.widgets.notes_te.toPlainText()
#
self.category.create_work_from_path(
name, self._file_or_folder_path, ignore_checks=True, notes=notes
name, self._file_or_folder_path, override_dcc=override_dcc, ignore_checks=True, notes=notes
)
self.accept()

def __get_matching_dccs(self, suffix):
"""Get the matching DCCs for the given suffix."""
for dcc_name, extensions in self.main_object.all_dcc_extensions.items():
if suffix in extensions:
yield dcc_name

def define_primary_ui(self):
_primary_ui = super().define_primary_ui()
# override the format with the defined file paths extension
_path_obj = Path(self._file_or_folder_path)
stem = _path_obj.stem
# replace all non-alphanumeric characters with underscores
_name = "".join([x if x.isalnum() else "_" for x in stem])
# get the matching extensions
matching_dccs = list(self.__get_matching_dccs(_path_obj.suffix))
matching_dccs.append("standalone")

update_dict = {
"override_dcc": {
"display_name": "DCC override",
"type": "combo",
"items": matching_dccs,
"value": matching_dccs[0],
"tooltip": "DCC to use for the work file",
},
"name": {
"display_name": "Name",
"type": "validatedString",