本文整理汇总了Python中shotgun_api3.Shotgun.upload方法的典型用法代码示例。如果您正苦于以下问题:Python Shotgun.upload方法的具体用法?Python Shotgun.upload怎么用?Python Shotgun.upload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shotgun_api3.Shotgun
的用法示例。
在下文中一共展示了Shotgun.upload方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _moveFilesToPublish
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload [as 别名]
def _moveFilesToPublish(self):
base_url = "http://bubblebathbay.shotgunstudio.com"
script_name = 'playBlastPublisher'
api_key = '718daf67bfd2c7e974f24e7cbd55b86bb101c4e5618e6d5468bc4145840e4558'
sgsrv = Shotgun(base_url = base_url , script_name = script_name, api_key = api_key, ensure_ascii=True, connect=True)
selectedShots = [item.text(0) for item in self.treeWidgetItems if item.checkState(0)]
if selectedShots:
for each in selectedShots:
episode = each.split('sh')[0]
shotName = '%s_sh%s' % (each.split('sh')[0], each.split('sh')[1].split('Lay')[0])
self.publishPath = self.publishingPath(episode, shotName)
for root, dirs, files in os.walk(self.shFldPath):
for fl in sorted(files):
if fl.endswith('.mov') and fl == '%s.mov' % each:
srcPath = os.path.join(root,fl)
self.playblastName = fl
while os.path.exists(os.path.join(self.publishPath, fl)):
allFiles= os.listdir(self.publishPath)
publishFiles = []
if allFiles:
for allFile in allFiles:
if allFile.endswith('.mov'):
publishFiles.append(allFile)
versionNumber = int(sorted(publishFiles)[-1].split('.v')[1].split('.mov')[0])
versionNumber += 1
if versionNumber < 10:
publishFileName = '%sLayout.v%03d.mov' % (shotName.replace('_', ''), versionNumber)
self.publishPath = os.path.join(self.publishPath, publishFileName)
self.playblastName = os.path.basename(self.publishPath)
else:
publishFileName = '%sLayout.v%02d.mov' % (shotName.replace('_', ''), versionNumber)
self.publishPath = os.path.join(self.publishPath, publishFileName)
self.playblastName = os.path.basename(self.publishPath)
shutil.copy2(srcPath, self.publishPath)
publishMovPath = os.path.join(self.publishingPath(episode, shotName), self.playblastName)
getShotTasks = sgsrv.find_one('Shot', filters = [["code", "is", shotName]], fields=['id', 'tasks'])
for key, values in getShotTasks.iteritems():
if key == 'tasks':
for value in values:
if value['name'] == 'Layout':
self.taskId = value['id']
if self.publishPath.endswith('review'):
self.publishPath = os.path.join(self.publishPath,fl)
self.playblastName = fl
data = { 'project': {'type':'Project','id': 66},
'code': self.playblastName,
'description': 'Layout playblast published',
'sg_path_to_movie': publishMovPath,
'sg_status_list': 'rev',
'entity': {'type':'Shot', 'id':getShotTasks['id']},
'sg_task': {'type':'Task', 'id':self.taskId},
'user': {'type':'HumanUser', 'id':92} }
result = sgsrv.create('Version', data)
result2 = sgsrv.upload("Version", result['id'], publishMovPath, "sg_uploaded_movie")
print "Done"
示例2: _pubBttn
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload [as 别名]
def _pubBttn(self):
base_url = "http://bubblebathbay.shotgunstudio.com"
script_name = 'playBlastPublisher'
api_key = '718daf67bfd2c7e974f24e7cbd55b86bb101c4e5618e6d5468bc4145840e4558'
sgsrv = Shotgun(base_url = base_url , script_name = script_name, api_key = api_key, ensure_ascii=True, connect=True)
selectedShots = sorted([item.text(0) for item in self.shotTreeWidgetItems if item.checkState(0)])
for shot in selectedShots:
if shot in self.srcPath.keys():
destPath = self._getPublishPath(shot)
srcPath = self.srcPath[str(shot)]
ext = os.path.splitext(srcPath)[-1]
# print os.path.basename(srcPath)
# while os.path.exists(os.path.join(str(destPath), os.path.basename(srcPath))):
# print "In Loop"
# print os.path.basename(srcPath)
# allFiles= os.listdir(destPath)
# publishFiles = []
# if allFiles:
# for allFile in allFiles:
# if allFile.endswith(ext):
# print allFile
# publishFiles.append(allFile)
# versionNumber = int(sorted(publishFiles)[-1].split('.v')[1].split(ext)[0])
# versionNumber += 1
# if versionNumber < 10:
# publishFileName = '%sLayout.v%03d%s' % (shotName.replace('_', ''), versionNumber, ext)
# self.publishPath = os.path.join(self.publishPath, publishFileName)
# self.playblastName = os.path.basename(self.publishPath)
# else:
# publishFileName = '%sLayout.v%02d%s' % (shotName.replace('_', ''), versionNumber, ext)
# self.publishPath = os.path.join(self.publishPath, publishFileName)
# self.playblastName = os.path.basename(self.publishPath)
# shutil.copy2(srcPath, destPath)
shotName = '%s_%s' % (self._getEpisodeName(shot), self._getShotName(shot))
getShotTasks = self.tk.shotgun.find_one('Shot', filters = [["code", "is", shotName]], fields=['id', 'tasks'])
taskName = self.comboBox.currentText()
self.playblastName = os.path.basename(srcPath)
publishMovPath = os.path.join(destPath, self.playblastName).replace('\\', '/')
shutil.copy2(srcPath, destPath)
for task in getShotTasks['tasks']:
if task['name'] == taskName:
taskId = task['id']
data = { 'project': {'type':'Project','id': 66},
'code': self.playblastName,
'description': 'Playblast published',
'sg_path_to_movie': publishMovPath,
'sg_status_list': 'rev',
'entity': {'type':'Shot', 'id':getShotTasks['id']},
'sg_task': {'type':'Task', 'id':taskId},
'user': {'type':'HumanUser', 'id':92} }
result = sgsrv.create('Version', data)
result2 = sgsrv.upload("Version", result['id'], publishMovPath, "sg_uploaded_movie")
print "Published %s" % self.playblastName
示例3: studioShotgun
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload [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,
#.........这里部分代码省略.........
示例4: __init__
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload [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 = {}
示例5: StoryboardFileManagement
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload [as 别名]
#.........这里部分代码省略.........
## Add this dict to the list of dict for updating the shot task list with.
self.taskList.append({'type': 'Task', 'id': self.myNewTask['id'], 'name': 'StoryBoard'})
## Now update the shots task list.
self.sgsrv.update(
'Shot',
self.getShotTasks['id'],
{
'project': {
'type':'Project',
'id':66
},
'tasks': self.taskList
}
)
print 'Successfully updated shot %s with task %s' % (self.shotName, self.taskId)
## Now create a version for this
print 'Adding version %s to %s now' % (self.boardName, self.shotName)
data = { 'project': {'type':'Project','id': 66},
'code': self.boardName,
'description': 'I am not a fluffy bunny!',
'sg_path_to_movie': self.pathToMovie,
'sg_status_list': 'rev',
'entity': {'type':'Shot', 'id':self.getShotTasks['id']},
'sg_task': {'type':'Task', 'id':self.taskId},
'sg_status_list': 'vwd',
'user': {'type':'HumanUser', 'id':53} }
result = self.sgsrv.create('Version', data)
## Now upload to shotgun
print 'Uploading version %s to %s now' % (self.boardName, self.shotName)
result2 = self.sgsrv.upload("Version", result['id'], self.pathToMovie, "sg_uploaded_movie")
self._turnOffCheckBox('%s.mov' % self.shotName)
else:
## Get the story board task id
for eachTask in self.taskList:
if eachTask['name'] == 'StoryBoard':
self.taskId = eachTask['id']
## Now create a version for this
print 'Adding version %s to %s now' % (self.boardName, self.shotName)
data = { 'project': {'type':'Project','id': 66},
'code': self.boardName,
'description': 'I am not a fluffy bunny!',
'sg_path_to_movie': self.pathToMovie,
'sg_status_list': 'rev',
'entity': {'type':'Shot', 'id':self.getShotTasks['id']},
'sg_task': {'type':'Task', 'id':self.taskId},
'sg_status_list': 'vwd',
'user': {'type':'HumanUser', 'id': 53} }
result = self.sgsrv.create('Version', data)
## Now upload to shotgun
print 'Uploading version %s to %s now' % (self.boardName, self.shotName)
result2 = self.sgsrv.upload("Version", result['id'], self.pathToMovie, "sg_uploaded_movie")
self._turnOffCheckBox('%s.mov' % self.shotName)
else:
print 'NO TASKS EXIST FOR %s skipping...' % self.shotName
self._turnOffCheckBox('%s.mov' % self.shotName)
def _turnOffCheckBox(self, shotName):
"""
Func for turning off the uploaded movies as we progress through them so if we error out we have
示例6: Shotgun
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload [as 别名]
from shotgun_api3 import Shotgun
url = "http://nad.shotgunstudio.com"
script_name = "ThibaultGenericScript"
key = "e014f12acda4074561022f165e8cd1913af2ba4903324a72edbb21430abbb2dc"
project_id = 146 # Demo Project
sg = Shotgun(url, script_name, key)
filename = "Z:/Groupes-cours/NAND999-A15-N01/Nature/assets/mod/.thumb/banc_02_full.jpg"
result = sg.upload("Version",1048,filename,"sg_uploaded_movie")
my_local_file = {
'attachment_links': [{'type':'Version','id':1048}],
'project': {'type':'Project','id':146}
}
asset = sg.find_one("Asset", [["code","is","afficheOeuvre"]], ["code"])
sg_user = sg.find_one('HumanUser', [['login', 'is', "houdon.thibault"]])
data = {
'project': {'type':'Project','id':project_id},
'note_links': [asset],
'user': sg_user,
'content':'Test',
'subject':"Thibault's Note on afficheOeuvre"
}
示例7: Shotgun
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import upload [as 别名]
payload = blob['data']
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)