from sg_publish_plugins import base
import sgtk
engine = sgtk.platform.current_engine()
sg = engine.shotgun
Project = engine.context.project
print engine.context
Entity: {'type': 'Asset', 'name': 'lanternbird_c', 'id': 1590}
Step: {'type': 'Step', 'name': 'Rigging', 'id': 15}
Task: {'type': 'Task', 'name': 'rig_lay', 'id': 6557}
User: {'name': '\xe5\xbc\xa0\xe9\xa2\x96', 'firstname': '\xe5\xbc\xa0\xe9\xa2\x96', 'lastname': None, 'image': 'https://sg-media-tokyo.s3-accelerate.amazonaws.com/6fa522b86fd4ba78843706277b51ba79286967f6/d0c8203cfc2bcab07e67d3f07d0256a847c0f2e2/1461885504631_t.jpg?response-content-disposition=filename%3D%221461885504631_t.jpg%22&x-amz-meta-user-id=189&x-amz-meta-user-type=HumanUser&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAYJG6Z4JIYKWGFO6T%2F20200720%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20200720T053043Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Security-Token=FwoGZXIvYXdzEH4aDH1IOQtjysHTzug3VSKvAYmLg2sCS0GXeiKCuhUhX0Nv5FJkwSXFKj7GY1kot1p4hAKHwPFB3CT8ISY3LvjXOzw%2Bm%2FBXDxJ61FSB6nY1EppbYU%2Fo8cvsFix8aRY7j%2B03FohUTOi1wQ71I2YDfpk6VehJvCNwtxYRPmZlpus%2BJ33ZiXeekQdKU8w%2F7QP7RefCdNs9FmZAHELiYjjFCcmLolxI%2B%2F6gR8JplZxxBWfposi%2FnHYtQxwzoatMygJbXWAouMDU%2BAUyLcUGAoobprmE8aWyHeD2KFWoDDFc%2FwoLXOqJNPgISLWepNRKugAT3zE3Lg7hOg%3D%3D&X-Amz-Signature=cbf6be77d1e45918774a8e425337076e6347968979eee01a43f52006f8363d1b', 'id': 189, 'login': 'zhangying', 'type': 'HumanUser', 'email': 'zhangying@proxi.business'}
Shotgun URL: https://buxi.shotgunstudio.com/detail/Task/6557
Additional Entities: []
Source Entity: {'content': 'rig_lay', 'image': 'https://sg-media-tokyo.s3-accelerate.amazonaws.com/6fa522b86fd4ba78843706277b51ba79286967f6/d89271ddc6dd372b6b3e9809fa8ae0aaaa9dbf86/8c2c6bf6c129d7ab_lanternbird_c_t.jpg?response-content-disposition=filename%3D%228c2c6bf6c129d7ab_lanternbird_c_t.jpg%22&x-amz-meta-user-id=189&x-amz-meta-user-type=HumanUser&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAYJG6Z4JISQC6NBHU%2F20200720%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20200720T031057Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Security-Token=FwoGZXIvYXdzEHwaDClog9zGU%2BZkAqZGBiKvATGOASoQZmklnVZLusjiHjiJpI%2B%2BdU2QoWZp8CDqAnDA6mMtxImc8HBDCnHCVSLGzQpm%2BHzritncZA60JCAHdzGofk%2BU5vyOSMTberdCH0DBdGTHDeNQwKCPQZLCD0KyzFVDXeRY0thsqR1gfYg73NfScXGUnvcRSkV72tA2c1tGseLbo3v5QywSDWMjcujo0QkDPbu3e9gT1m7rzOGxIKLPqj5GdlLtPmjFRMNcWRIo2onU%2BAUyLWj1cQIfbxj7QUeu%2BT%2FjftZHdiPXA9ZdlCu%2FltSqMi6tUeb2lKWC11nGmeI%2BkQ%3D%3D&X-Amz-Signature=598a5b110018e604e1ae390f09df8f00ca9e72aadb0b484685bc21e1ddbcf919', 'type': 'Task', 'id': 6557, 'entity': {'type': 'Asset', 'id': 1590, 'name': 'lanternbird_c'}}>
class CheckModPublish(base.PluginBase):
description = u'检查层级是否符合publish要求.'
name = u'层级检查'
item_filters = ['maya.session']
@property
def icon(self):
return icons.path('hierarchy.png')
def validate(self, settings, item):
import sgtk
engine = sgtk.platform.current_engine()
temp = engine.get_template_by_name('shot_work')
field_dict = {'Sequence':'c20', 'Shot':'120', 'Step':'rongjie'}
print ' '
print temp
print temp.apply_fields(field_dict)
<Sgtk TemplatePath shot_work: shots/{Sequence}/{Shot}/{Step}>
W:\mtz\shots\c20\120\rongjie