-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_init_wdg.py
More file actions
212 lines (154 loc) · 6.89 KB
/
app_init_wdg.py
File metadata and controls
212 lines (154 loc) · 6.89 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
###########################################################
#
# Copyright (c) 2005, Southpaw Technology
# All Rights Reserved
#
# PROPRIETARY INFORMATION. This software is proprietary to
# Southpaw Technology, and is not to be reproduced, transmitted,
# or disclosed in any way without written permission.
#
#
__all__ = [ 'PyMayaInit', 'PyFlashInit', 'PyRepoActionInit', 'PyHoudiniInit', 'PyXSIInit']
from pyasm.biz import PrefSetting, Project
from pyasm.web import Html, WebContainer, Widget, DivWdg
from pyasm.widget import HiddenWdg
class PyMayaInit(Widget):
def get_display(my):
div = DivWdg()
# this is to prevent this function from being run in other tabs
web = WebContainer.get_web()
user = WebContainer.get_user_name()
local_dir = web.get_local_dir()
context_url = web.get_site_context_url().to_string()
http_server = web.get_base_url().to_string()
upload_url = web.get_upload_url()
project_code = Project.get_project_code()
div.add_behavior( {
'type': 'load',
'cbjs_action': '''
var js_files = [
"/context/javascript/PyMaya.js",
];
var supp_js_files = [
"/context/spt_js/fx_anim.js",
"/context/javascript/PyHoudini.js",
"/context/javascript/PyXSI.js"
];
var set_up = function() {
try {
app = new PyMaya(); }
catch(e) {
app = null;
}
if (app) {
app.user = '%(user)s';
app.local_dir = '%(local_dir)s';
app.context_url = '%(context_url)s';
app.base_url = '%(server)s';
app.upload_url = '%(upload_url)s';
app.project_code = '%(project_code)s';
}
}
spt.dom.load_js(js_files, function() {PyMaya(); set_up();});
spt.dom.load_js(supp_js_files, function() {});
'''%{
'user': user,
'local_dir': local_dir,
'context_url' : context_url,
'server': http_server,
'upload_url': upload_url,
'project_code': project_code }
})
#pref = PrefSetting.get_value_by_key("use_java_maya")
#if pref == "true":
# html.writeln("<script>app.use_java = true</script>")
handoff_dir = web.get_client_handoff_dir(no_exception=True)
if not handoff_dir:
print "WARNING: handoff_dir is empty in the TACTIC config file"
server = web.get_http_host()
application = "maya"
div.add( HiddenWdg("user", user) )
div.add( HiddenWdg("handoff_dir", handoff_dir) )
div.add( HiddenWdg("project_code", project_code) )
div.add( HiddenWdg("local_dir", local_dir) )
div.add( HiddenWdg("server_name", server) )
div.add( HiddenWdg("application", application) )
#div.add( HiddenWdg("base_url", server) )
#div.add( HiddenWdg("upload_url", upload_url) )
return div
class PyFlashInit(Widget):
def get_display(my):
web = WebContainer.get_web()
html = Html()
html.writeln("<script>var pyflash=new PyFlash()</script>")
# add in parameters for pyflash
user = WebContainer.get_user_name()
html.writeln("<script>pyflash.user = '%s'</script>" % user)
local_dir = web.get_local_dir()
html.writeln("<script>pyflash.local_dir = '%s'</script>" % local_dir)
server = web.get_base_url().to_string()
html.writeln("<script>pyflash.server_url = '%s'</script>" % server)
context_url = web.get_site_context_url().to_string()
html.writeln("<script>pyflash.context_url = '%s%s'</script>" % (server, context_url))
upload_url = web.get_upload_url()
html.writeln("<script>pyflash.upload_url = '%s'</script>" % upload_url)
return html
class PyHoudiniInit(Widget):
def get_display(my):
web = WebContainer.get_web()
user = WebContainer.get_user_name()
local_dir = web.get_local_dir()
context_url = web.get_site_context_url().to_string()
server = web.get_base_url().to_string()
upload_url = web.get_upload_url()
html = Html()
html.writeln('<script language="JavaScript" src="resource:///res/RunHCommand.js"></script>')
html.writeln('''\n<script>try{ app = new PyHoudini(); }
catch(e){
app = null;}
if (app) {
app.user = '%(user)s';
app.local_dir = '%(local_dir)s';
app.context_url = '%(context_url)s';
app.base_url = '%(server)s';
app.upload_url = '%(upload_url)s';
app.project_code = '%(project_code)s';} </script>'''%{'user': user,
'local_dir': local_dir,
'context_url' : context_url,
'server': server,
'upload_url': upload_url,
'project_code': Project.get_project_code()})
return html
class PyXSIInit(Widget):
def get_display(my):
web = WebContainer.get_web()
user = WebContainer.get_user_name()
local_dir = web.get_local_dir()
context_url = web.get_site_context_url().to_string()
server = web.get_base_url().to_string()
upload_url = web.get_upload_url()
html = Html()
html.writeln('''\n<script>try{ app = new PyXSI(); }
catch(e){
app = null;}
if (app) {
app.user = '%(user)s';
app.local_dir = '%(local_dir)s';
app.context_url = '%(context_url)s';
app.base_url = '%(server)s';
app.upload_url = '%(upload_url)s';
app.project_code = '%(project_code)s';} </script>'''%{'user': user,
'local_dir': local_dir,
'context_url' : context_url,
'server': server,
'upload_url': upload_url,
'project_code': Project.get_project_code()})
return html
class PyRepoActionInit(Widget):
def get_display(my):
html = Html()
html.writeln("<script>var pyp4=new PyPerforce()</script>")
upload_url = WebContainer.get_web().get_upload_url()
html.writeln("<script>var tactic_repo=new TacticRepo()</script>")
html.writeln("<script>tactic_repo.upload_url='%s'</script>" %upload_url)
return html