本文整理汇总了Python中shotgun_api3.Shotgun.upload_thumbnail方法的典型用法代码示例。如果您正苦于以下问题:Python Shotgun.upload_thumbnail方法的具体用法?Python Shotgun.upload_thumbnail怎么用?Python Shotgun.upload_thumbnail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shotgun_api3.Shotgun
的用法示例。
在下文中一共展示了Shotgun.upload_thumbnail方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: studioShotgun
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload_thumbnail [as 别名]
class studioShotgun(object):
def __init__(self, path, name, key, project):
self.SERVER_PATH = path
self.SCRIPT_NAME = name
self.SCRIPT_KEY = key
self.project_id = project
self.sg = Shotgun(self.SERVER_PATH, self.SCRIPT_NAME, self.SCRIPT_KEY)
#----------------------------------------------------------------------
## set Project id by ID
def setProjectId(self, newId):
self.project_id = newId
#----------------------------------------------------------------------
## set Project id by ID
def setProjectName(self, name):
newId = 0
projects = self.sg.find('Project', [], ['name'])
for project in projects:
if project['name'] == name:
newId = project['id']
self.project_id = newId
#----------------------------------------------------------------------
## find asset by name
def findAssetByName(self, name):
fields = ['id', 'code', 'sg_asset_type', 'tasks']
filters = [['project', 'is', {'type': 'Project', 'id': self.project_id}], ['code', 'is', name]]
result = self.sg.find('Asset', filters, fields)
return result
#----------------------------------------------------------------------
## find shot by name
def findShotByName(self, episode, shot):
fields = ['id', 'code', 'sg_asset_type', 'tasks', 'sg_sequence']
filters = [['project', 'is', {'type': 'Project', 'id': self.project_id}], ['code', 'is', shot]]
result = self.sg.find('Shot', filters, fields)
for x in result:
name = x['sg_sequence']['name'].split('_')[0]
if name == episode:
return x
return []
#----------------------------------------------------------------------
## upload thumbnail to asset
def uploadThumbnail(self, asset, thumbnail):
upload = 0
asset = self.findAssetByName(asset)
if asset:
upload = self.sg.upload_thumbnail("Asset", asset[0]['id'], thumbnail)
return upload
#----------------------------------------------------------------------
## create new asset
def createAsset(self, asset, assetType, template, assetFile='', description=''):
## find asset
asset = self.findAssetByName(asset)
if not asset:
## create asset + task template
filters = [['code', 'is', template]]
template = self.sg.find_one('TaskTemplate', filters)
data = {'project': {'type': 'Project', 'id': self.project_id},
'code': asset,
'description': description,
'sg_asset_type': assetType,
'sg_url_perforce': assetFile,
'task_template': template}
asset = self.sg.create('Asset', data)
return asset
#----------------------------------------------------------------------
## update file path in asset
def updateAssetFilePath(self, asset, filename):
asset = self.findAssetByName(asset)
data = {'sg_url_perforce': filename}
asset = self.sg.update("Asset", asset[0]['id'], data)
return asset
#----------------------------------------------------------------------
## create new version
def createVersion(self, shotId, taskId, userId, filename, comment=''):
curTime = datetime.now().strftime('%Y.%m.%d_%H.%M')
fname = str(filename.split('/')[-1].split('.')[0]) + '_' + curTime
data = {'project': {'type': 'Project', 'id': self.project_id},
'code': fname,
'description': comment,
#.........这里部分代码省略.........
示例2: Shotgun
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload_thumbnail [as 别名]
sg = Shotgun(config['shotgun_url'], config['script_name'], config['script_api_key'], 'api3_preview')
if method == 'find':
result = sg.find(payload['entity'], payload['filters'], payload['fields'], payload['order'], payload['filter_operator'], payload['limit'], payload['retired_only'])
elif method == 'find_one':
result = sg.find_one(payload['entity'], payload['filters'], payload['fields'], payload['order'], payload['filter_operator'])
elif method == 'create':
result = sg.create(payload['entity'], payload['data'])
elif method == 'update':
result = sg.update(payload['entity'], payload['id'], payload['data'])
elif method == 'delete':
result = sg.delete(payload['entity'], payload['id'])
elif method == 'upload':
result = sg.upload(payload['entity'], payload['id'], payload['path'], payload['field_name'], payload['display_name'])
elif method == 'upload_thumbnail':
result = sg.upload_thumbnail(payload['entity'], payload['id'], payload['path'])
elif method == 'schema_field_read':
result = sg.schema_field_read(payload['entity'])
elif method == 'schema_field_create':
result = sg.schema_field_create(payload['entity'], payload['type'], payload['name'], payload['attrs'])
elif method == '_url_for_attachment_id':
entity_id = payload['id']
# Do a lot of legwork (based on Shotgun.download_attachment())
sid = sg._get_session_token()
domain = urlparse(sg.base_url)[1].split(':',1)[0]
cj = cookielib.LWPCookieJar()
c = cookielib.Cookie('0', '_session_id', sid, None, False, domain, False, False, "/", True, False, None, True, None, None, {})
cj.set_cookie(c)
cookie_handler = urllib2.HTTPCookieProcessor(cj)
urllib2.install_opener(urllib2.build_opener(cookie_handler))
示例3: __init__
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload_thumbnail [as 别名]
#.........这里部分代码省略.........
#data['user']
if task != None:
filters = [['content','is',task],['entity','is',shot]]
taskID = self.sg.find_one('Task',filters)
data['sg_task']=taskID
#if final == True and 'send
# in case we're putting a client version in here we need this code.
# we are expecting a field called self.sg_client_name in the version table.
# please make sure you create this in the shotgun setup
# read the schema and if the client_name is not found, create it.
'''
versionFields = self.sg.schema_field_read('Version')
if 'sg_client_name' not in versionFields and clientName != None:
newField = self.sg.schema_field_create('Version','text','Client Name')
if clientName != None :
data['sg_client_name'] = clientName
#'user': {'type':'HumanUser', 'id':165} }
# here we need to create a field for storing the source file that created this version.
# if it's not there, create the field, and if it's there just update it.
if 'sg_source_file' not in versionFields and sourceFile != None:
newField = self.sg.schema_field_create('Version','text','Source File')
if sourceFile != None:
data['sg_source_file'] = sourceFile
'''
versionData = self.sg.create('Version',data)
# handle the thumbnail grabbing here
middleFrame = (int(firstFrame) + int(lastFrame)) / 2
padding, padString = fxpipe.framePad(framePath)
paddedFrame = padString % (middleFrame)
if makeThumb == True:
thumbData = self.sg.upload_thumbnail('Version', versionData['id'], framePath.replace(padding,paddedFrame))
if makeThumbShot == True:
thumbData = self.sg.upload_thumbnail('Shot', shot['id'], framePath.replace(padding,paddedFrame))
return versionData
#add a task version to the system
def versionCreateTask(self, project, shot, verName, description, framePath, firstFrame, lastFrame, task, sourceFile = ''):
'''
DEPRECATED : USE versionCreate instead with the task='TASKNAME'
Parameters : (project, shot, verName, description, framePath, firstFrame, lastFrame, task, sourceFile = '')
Output : Version ID
'''
filters = [['content','is',task],['entity','is',shot]]
taskID = self.sg.find_one('Task',filters)
data = {'project': project,
'code': verName,
'description': description,
'self.sg_path_to_frames': framePath,
'frame_range': str(firstFrame) + '-' + str(lastFrame),
'self.sg_first_frame' : firstFrame,
'self.sg_last_frame' : lastFrame,
#'self.sg_uploaded_movie': '/Users/throb/Downloads/test.m4v',
#'self.sg_first_frame': 1,
#'self.sg_last_frame': 100,
'self.sg_status_list': 'rev',
'self.sg_task': taskID,
'entity': shot}
# here we need to create a field for storing the source file that created this version.
# if it's not there, create the field, and if it's there just update it.
try:
tmp2 = {}
示例4: Shotgun
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload_thumbnail [as 别名]
# Globals
# ---------------------------------------------------------------------------------------------
DEFAULT_SHOTGUN_API = "/usr/share/pyshared/shotgun_api3.py" # Place this in your Pyshared directory
SERVER_PATH = "https://yourshotgunsite.shotgunstudio.com"
SCRIPT_NAME = "test_001"
SCRIPT_KEY = 'shotgungeneratedkeynumber' # Script key number
# ---------------------------------------------------------------------------------------------
# Project Id's
# ---------------------------------------------------------------------------------------------
# Project Widow ID
PROJECT = {'type':'Project', 'id':64}
# ---------------------------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------------------------
sg = Shotgun(SERVER_PATH, SCRIPT_NAME, SCRIPT_KEY)
print "\n\nUploading thumbnail to "+SERVER_PATH+"\n\n"
if __name__ == '__main__':
version_id = 23 # Version ID
thumbnail = '/home/user/Renders/testing.jpg' # Replace this
result = sg.upload_thumbnail("Version",version_id,thumbnail) # magic happens.
print result
print ""+SCRIPT_NAME+"...complete!\n"