forked from shotgunsoftware/tk-multi-perforce
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
100 lines (74 loc) · 3.34 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
91
92
93
94
95
96
97
98
99
100
# Copyright (c) 2013 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.
"""
General Perforce connection commands
"""
import os
import sgtk
from sgtk import TankError
class MultiPerforce(sgtk.platform.Application):
def init_app(self):
"""
Called as the app is being initialized
"""
self.log_debug("%s: Initializing..." % self)
# register commands:
self.engine.register_command("Perforce Connection...", self.show_connection_dlg)
# (TODO) - these commands aren't quite finished yet!
#self.engine.register_command("Check Out Scene...", self.check_out_scene)
#self.engine.register_command("Revert Changes...", self.revert_scene_changes)
#self.engine.register_command("Show Pending Publishes...", self.show_pending_publishes)
# support connecting on startup:
# Note, this runs every time the app is re-initialized (the engine is restarted).
# however, the UI will only be shown when a connection can't be made with the
# previous/cached settings so this should be infrequently!
if self.engine.has_ui:
connect_on_startup = self.get_setting("connect_on_startup")
if connect_on_startup:
self.log_debug("Attempting to connect to Perforce...")
self.__connect_on_startup()
def destroy_app(self):
"""
Called when the app is being cleaned up
"""
self.log_debug("%s: Destroying..." % self)
self.log_debug("Destroying tk-multi-perforce")
def show_connection_dlg(self):
"""
Show the Perforce connection details dialog.
"""
tk_multi_perforce = self.import_module("tk_multi_perforce")
tk_multi_perforce.open_connection(self)
def check_out_scene(self):
"""
Check out the current scene from Perforce.
"""
tk_multi_perforce = self.import_module("tk_multi_perforce")
tk_multi_perforce.check_out_current_scene()
def revert_scene_changes(self):
"""
Discard any changes to the current scene and revert.
"""
tk_multi_perforce = self.import_module("tk_multi_perforce")
tk_multi_perforce.revert_scene_changes()
def show_pending_publishes(self):
"""
Show all publishes that are pending in Perforce.
"""
tk_multi_perforce = self.import_module("tk_multi_perforce")
tk_multi_perforce.show_pending_publishes()
def __connect_on_startup(self):
"""
Called when the engine starts to ensure that a connection to Perforce
can be established. Prompts the user for password/connection details
if needed
"""
tk_multi_perforce = self.import_module("tk_multi_perforce")
tk_multi_perforce.connect(self)