This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
app.py
90 lines (72 loc) · 2.84 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Copyright (c) 2015 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
"""
Multi Publish
"""
import os
import tank
class MultiPublish(tank.platform.Application):
def init_app(self):
"""
Called as the application is being initialized
"""
tk_multi_publish = self.import_module("tk_multi_publish")
self._publish_handler = tk_multi_publish.PublishHandler(self)
# register commands:
display_name = self.get_setting("display_name")
# "Publish Render" ---> publish_render
command_name = display_name.lower().replace(" ", "_")
if command_name.endswith("..."):
command_name = command_name[:-3]
params = {
"short_name": command_name,
"title": "%s..." % display_name,
"description": "Publishing of data into Shotgun",
# dark themed icon for engines that recognize this format
"icons": {
"dark": {
"png": os.path.join(
os.path.dirname(__file__),
"resources",
"publish_menu_icon.png"
)
}
}
}
self.engine.register_command("%s..." % display_name,
self._publish_handler.show_publish_dlg,
params)
@property
def context_change_allowed(self):
"""
Specifies that context changes are allowed.
"""
return True
def destroy_app(self):
self.log_debug("Destroying tk-multi-publish")
def copy_file(self, source_path, target_path, task):
"""
Utility method to copy a file from source_path to
target_path. Uses the copy file hook specified in
the configuration
"""
self.execute_hook("hook_copy_file",
source_path=source_path,
target_path=target_path,
task=task)
def post_context_change(self, old_context, new_context):
"""
Runs after a context change has completed.
:param old_context: The sgtk.context.Context being switched from.
:param new_context: The sgtk.context.Context being switched to.
"""
self.log_debug("Context change. Rebuilding outputs...")
self._publish_handler.build_outputs()
self.log_debug("Outputs Rebuilt!")