1
+ #!/usr/bin/env python
2
+ # -*- coding:utf-8 -*-
3
+
4
+ import sys
5
+ import nuke
6
+ sys .path .append (r"C:\cgteamwork\bin\lib\pyside" )
7
+ sys .path .append (r"C:\cgteamwork\bin\base" )
8
+ SERVER_DI = "to.xm.cgteamwork.com:1003"
9
+
10
+ '''请注意命名的冲突'''
11
+ class CreateTask ():
12
+ def __init__ (self ):
13
+ import cgtw
14
+ import cgtw2
15
+ try :
16
+ self ._t_tw = cgtw .tw ()
17
+ self ._t_tw2 = cgtw2 .tw ()#cgtw2 api 用来获取 a_flow_id
18
+ except :
19
+ nuke .message ('Please open CGteamwork' )
20
+ return False
21
+ def getProjectDatabase (self ,project ):
22
+ t_info = self ._t_tw .info_module ("public" , "project" )
23
+ filters = [
24
+ ["project.code" , "=" , project ],
25
+ ]
26
+ t_info .init_with_filter (filters )
27
+ fields = ["project.database" ]
28
+ database = t_info .get (fields )[0 ]['project.database' ]
29
+ return database
30
+
31
+ # 创建eps场次号(如果存在则忽略)************************************
32
+ def Create_eps (self , project , eps ):
33
+ """
34
+ 创建集数信息
35
+ :param project:
36
+ :eps: 'ep001'
37
+ :return:
38
+ """
39
+ eps_List = []
40
+ projectDb = self .getProjectDatabase (project )
41
+ eps_name = self .getProjectEps (project )
42
+ for i in range (len (eps_name )):
43
+ eps_List .append (eps_name [i ]['eps.eps_name' ])
44
+ t_info = self ._t_tw .info_module (projectDb , "eps" )
45
+ Create_data = {"eps.eps_name" : eps }
46
+ if Create_data ['eps.eps_name' ] not in eps_List :
47
+ t_info .create (Create_data )
48
+ return True
49
+ else :
50
+ return False
51
+
52
+ # 得到eps场次名称******************************************
53
+ def getProjectEps (self , project ):
54
+ eps_List = []
55
+ projectDb = self .getProjectDatabase (project )
56
+ t_info = self ._t_tw .info_module (projectDb , "eps" )
57
+ filters = []
58
+ t_info .init_with_filter (filters )
59
+ fields = ["eps.eps_name" ]
60
+ data = t_info .get (fields )
61
+ for i in range (len (data )):
62
+ eps_List .append (data [i ]['eps.eps_name' ])
63
+ return eps_List
64
+
65
+ #得到特定场次下面的镜头号****************************************
66
+ def getEpsShot (self ,project ,eps ):
67
+ '''
68
+ :param project:查询项目
69
+ :param eps: 场次号,例如:ep001
70
+ :return: 查询场次号下面所有的镜头号列表
71
+ '''
72
+ shotInfo = []
73
+ projectDb = self .getProjectDatabase (project )
74
+ t_info = self ._t_tw .info_module (projectDb , 'shot' )
75
+ filters = [
76
+ ["eps.eps_name" ,"=" ,eps ]
77
+ ]
78
+ t_info .init_with_filter (filters )#过滤器
79
+ fields = ["shot.shot" ]#查询的内容
80
+ data = t_info .get (fields )
81
+ for i in data :
82
+ shotInfo .append (i ['shot.shot' ])
83
+ return shotInfo
84
+
85
+ def createShotTask (self ,project ,eps ,shot ,act ,pipeline_id ,pipeline_name ):
86
+ print eps ,shot ,act #改
87
+ projectDb = self .getProjectDatabase (project )
88
+ t_info = self ._t_tw .info_module (projectDb ,'shot' )
89
+ if act :
90
+ filters = [['eps.eps_name' ,'=' ,eps ],
91
+ ['shot.shot' ,'=' ,shot ]
92
+ ['eps.act' ,'=' ,act ] #GAI
93
+ ]
94
+ else :
95
+ filters = [['eps.eps_name' ,'=' ,eps ],
96
+ ['shot.shot' ,'=' ,shot ]
97
+ # ['eps.act','=',act] #GAI
98
+ ]
99
+ t_info .init_with_filter (filters )
100
+ join_id = t_info .get_id_list ()
101
+ t_task_info = self ._t_tw .task_module (projectDb , "shot" )
102
+ t_task_info .init_with_filter (filters )
103
+
104
+ t_pipeline_id_list = self ._t_tw2 .pipeline .get_id (projectDb , [['entity_name' , '=' , pipeline_name ], 'and' , ['module' , '=' , 'shot' ],'and' ,['module_type' , '=' , 'task' ]])
105
+ t_flow_list = self ._t_tw2 .flow .get_data (projectDb , t_pipeline_id_list )
106
+ t_flow_id = t_flow_list [0 ]['flow_id' ]
107
+
108
+ t_task_info .create_task (join_id [0 ],pipeline_id ,pipeline_name ,a_flow_id = t_flow_id , a_task_name = "" )
109
+
110
+
111
+ def setShotTask (self ,project ,eps ,shot ,act ,pipeline_name ,artist_name ,status = '' ,description = '' ):
112
+
113
+ projectDb = self .getProjectDatabase (project )
114
+ t_task_info = self ._t_tw .task_module (projectDb ,"shot" )
115
+ if act :
116
+ filters = [['eps.eps_name' ,'=' ,eps ],
117
+ ['shot.shot' ,'=' ,shot ],
118
+ # ['eps.act','=',act],#GAI
119
+ ['task.pipeline' ,'=' ,pipeline_name ]]
120
+ else :
121
+ filters = [['eps.eps_name' ,'=' ,eps ],
122
+ ['shot.shot' ,'=' ,shot ],
123
+ ['eps.act' ,'=' ,act ],#GAI
124
+ ['task.pipeline' ,'=' ,pipeline_name ]]
125
+
126
+ t_task_info .init_with_filter (filters )
127
+ t_task_info .set ({'task.artist' :artist_name ,'task.status' :status ,'task.dddd' :description })#
128
+ id = t_task_info .get (['task.id' ])
129
+
130
+ self .Send_Message (projectDb ,id ,eps ,shot ,pipeline_name ,artist_name ,description = description )
131
+ self .MergeNote (projectDb ,eps ,shot )
132
+
133
+ def getArtistId (self ,artist ):
134
+ t_info = self ._t_tw .info_module ("public" ,'account' )
135
+ filters = [
136
+ ['account.name' ,'=' ,artist ]
137
+ ]
138
+ t_info .init_with_filter (filters )
139
+
140
+ # data = t_info.get(['account.name','account.project_permission','account.group','account.department'])
141
+ data = t_info .get (['account.id' ])
142
+ name_id = []
143
+ name_id .append (data [0 ]['account.id' ])
144
+ return name_id
145
+
146
+ def Send_Message (self ,database ,id ,eps ,shot ,pipeline_name ,artist_name ,description = '' ):
147
+ projectDb = database
148
+ model = 'shot'
149
+ model_type = 'task'
150
+ account_id_list = self .getArtistId (artist_name )
151
+ task_id = id [0 ]['id' ]
152
+ message = str (eps + ' ' + shot + ' ' + pipeline_name + ' ' + ':' + description + ' ' + '\n ' + 'Assign to ' + artist_name )
153
+ print projectDb ,model ,model_type ,task_id ,account_id_list
154
+ self ._t_tw .con ()._send ("c_msg" ,"send_link_task" , {"db" :projectDb , "module" :model , "module_type" :model_type , "task_id" : task_id , "content" :message , "account_id_array" :account_id_list ,'is_show_info_data' :True })
155
+
156
+ def getPipelineName (self ,project ):
157
+ projectDb = self .getProjectDatabase (project )
158
+ t_task_info = self ._t_tw .pipeline (projectDb )
159
+ pipelineList = t_task_info .get_with_module ('shot' ,['name' ,'#id' ])
160
+
161
+ return pipelineList
162
+ # filters = []
163
+ # t_task_info.init_with_filter(filters)
164
+ # data = t_task_info.get(["task.pipeline"])
165
+ # return data
166
+
167
+ def getshotInfo (self ,project ,epsLis ,shotLis ):
168
+
169
+ projectDb = self .getProjectDatabase (project )
170
+ t_info = self ._t_tw .info_module (projectDb , "shot" )
171
+ filters = [['eps.eps_name' ,'in' ,epsLis ],
172
+ ['shot.shot' ,'in' ,shotLis ]
173
+ ]
174
+ t_info .init_with_filter (filters )
175
+ data = t_info .get (['eps.eps_name' ,'shot.shot' ])
176
+
177
+ return data
178
+
179
+ def getArtistName (self ):
180
+
181
+ t_info = self ._t_tw .info_module ("public" ,'account' )
182
+
183
+ filters = [['account.name' ,'has' ,'%' ]]
184
+ t_info .init_with_filter (filters )
185
+
186
+ # data = t_info.get(['account.name','account.project_permission','account.group','account.department'])
187
+ data = t_info .get (['account.name' ])
188
+ name = []
189
+ for i in range (len (data )):
190
+ name .append (data [i ]['account.name' ])
191
+ return name
192
+
193
+ def MergeNote (self ,database ,eps ,shot ):#合并任务模块的描述统计到镜头描述
194
+ t_task = self ._t_tw .task_module (database , "shot" )
195
+ filters = [['eps.eps_name' ,'=' ,eps ],
196
+ ['shot.shot' ,'=' ,shot ]
197
+ ]
198
+ t_task .init_with_filter (filters )
199
+ data_note = t_task .get (['task.dddd' ])
200
+ string = ''
201
+ for data in data_note :
202
+ string += data ['task.dddd' ]
203
+ string += ' '
204
+
205
+ t_info = self ._t_tw .info_module (database , "shot" )
206
+ t_info .init_with_filter (filters )
207
+ t_info .set ({'shot.vfx_note' : string })
208
+
209
+
210
+
211
+ # if __name__ == '__main__':
212
+ # Shot = CreateTask()
213
+ # Shot.setShotTask("TWE","ACT2",'S030',"efx",'wadfgfdgr','11')
214
+
215
+ # pipelineNameLis = []
216
+ # pipelineNameDic = {}
217
+ # for i in range(len(pipelineName)):
218
+ # pipelineNameDic.update({pipelineName[i]['name']: pipelineName[i]['id']})
219
+ # pipelineNameLis.append(pipelineName[i]['name'])
220
+ # print pipelineNameDic,pipelineNameLis
221
+ # Shot.createShotTask("TWE", "ACT1", "S031",'01F99FCE-3407-E541-E14C-DE4BD9D17AB7','animation')
222
+ # Shot.setShotTask("TWE", "ACT1", "S032","animation","123456")
223
+ #TWE ACT1 S031 01F99FCE-3407-E541-E14C-DE4BD9D17AB7 animation
224
+ # data = Shot.setShotTask("TWE", "ACT1", "S032","animation")
225
+
226
+ # print unicode(data[0]['task.artist'])
227
+
228
+ print '----------------------------------------------------'
0 commit comments