本文整理汇总了Python中shotgun_api3.Shotgun类的典型用法代码示例。如果您正苦于以下问题:Python Shotgun类的具体用法?Python Shotgun怎么用?Python Shotgun使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Shotgun类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: submitShotgunTicket
def submitShotgunTicket(output, jobList):
currentuser = str(User.currentUser().name())
title = "AtS - %s"%currentuser
desc = []
desc.append(output+"\n")
desc.append("JOBLIST:")
for job in jobList:
desc.append(str(job.key())+" - "+str(job.name()))
sg = Shotgun(SERVER_PATH, SCRIPT_USER, SCRIPT_KEY)
id = sg.find("HumanUser",[['login','is',currentuser]],['id'])
userid = id[0]
ticket_data = {
'created_by': {'type':'HumanUser','id':userid['id']},
'title': title,
'description': "\n".join(desc),
'addressings_to':[{'type':'Group', 'id':19}, {'type':'HumanUser','id':userid['id']}],
'project': {'type':'Project', 'id':178},
'sg_service': {'type':'CustomNonProjectEntity01', 'id':27},
}
sg_ticket = sg.create('Ticket', ticket_data, ['id'])
new_ticket_url = SERVER_PATH + "/detail/Ticket/" + str(sg_ticket['id'])
QDesktopServices.openUrl( QUrl(new_ticket_url) )
示例2: main
def main(notebookName):
#Get your developer token here: https://www.evernote.com/api/DeveloperToken.action and put it here
dev_token = 'yourEvernoteDevKey'
#Put your Shotgun script details here
sg = Shotgun('https://yourSite.shotgunstudio.com','evernote-shotgun','yourScriptKey')
#Put the Shotgun HumanUser ID here for the person you want to appear as the Note's author in Shotgun
sgUserId = 45
sgUser = sg.find_one("HumanUser",[['id', 'is', sgUserId]])
#Establish a connection to Evernote and store note and user data
client = EvernoteClient(token=dev_token, sandbox=False)
userStore = client.get_user_store()
user = userStore.getUser()
noteStore = client.get_note_store()
#Check if the supplied notebook exists, and if it does, send to processNotebook()
print('\nFinding notebook')
notebooks = noteStore.listNotebooks()
notebookNames = [notebook.name for notebook in notebooks]
if notebookName not in notebookNames:
print('\nSorry, there are no notebooks in your account named {0}'.format(notebookName))
else:
for notebook in notebooks:
if notebook.name == notebookName:
print('\nProcessing notebook - BEGIN')
processNotebook(noteStore, notebook, sg, sgUser)
print('\nProcessing notebook - DONE\n')
else:
continue
示例3: getProjects
def getProjects():
site = 'https://chimneypot.shotgunstudio.com'
scriptName = 'AssetBrowser'
scriptKey = 'c35ab5f5322d4b1e8b6488bb315c03e5f38881ea'
repo = '/mnt/karramba/'
rootList = ['film', 'out', 'ref', 'src', 'temp']
filmList = ['assets', 'sequences']
assetList = ['light', 'material', 'mattepaint', 'model', 'rig', 'shader', 'textures']
shotList = ['anim', 'comp', 'data', 'fx', 'light', 'out', 'src', 'tmp']
sqList = ['anim', 'comp', 'data', 'fx', 'light', 'out', 'shots']
dataList = ['cache', 'geo', 'render', 'shadowmap', 'sim', 'track', 'photonmap']
outList = ['dailies', 'hires']
prName = raw_input('Print project name:')
prPath = repo + prName
if not os.path.exists(prPath):
os.mkdir(prPath)
for i in rootList:
os.makedirs(prPath + os.sep + i)
for i in filmList:
os.makedirs(prPath + os.sep + 'film' + os.sep + i)
for i in assetList:
os.makedirs(prPath + os.sep + 'film' + os.sep + 'assets' + os.sep + i)
for i in outList:
os.makedirs(prPath + os.sep + 'out' + os.sep + i)
sg = Shotgun(site, scriptName, scriptKey)
sg.create('Project', {'name':prName})
示例4: addSrc
def addSrc():
repo = '/mnt/karramba'
shotFoldList = ['anim', 'comp', 'data', 'fx', 'light', 'out', 'src', 'tmp']
seqFoldList = ['anim', 'comp', 'data', 'fx', 'light', 'out', 'shots']
dataFoldList = ['cache', 'geo', 'render', 'shadowmap', 'sim', 'track', 'photonmap']
outFoldList = ['dailies', 'hires']
site = 'https://chimneypot.shotgunstudio.com'
scriptName = 'addSrc'
scriptKey = 'd7dac4e2c55faf486875dfb944ffc9d8e49a0c44'
sg = Shotgun(site, scriptName, scriptKey)
projList = sg.find('Project', [], ['name'])
for i in projList:
print 'id:' + str(i['id']) + ' ' + i['name']
prId = int(raw_input('Print project id:'))
proj = sg.find_one('Project', [['id','is',prId]], ['name'])
if not [x for x in os.listdir(repo) if x==proj['name']]:
print "Project doesn't exist in repository"
return
s = os.sep
prPath = repo + s + proj['name']
seqPath = prPath + s + 'film' + s + 'sequences'
seqList = os.listdir(prPath + s + 'src')
for i in seqList:
sequenceFold = prPath + s + 'film' + s + 'sequences'
os.makedirs(sequenceFold + s + i)
for j in seqFoldList:
os.makedirs(sequenceFold + s + i + s + j)
for d in dataFoldList:
os.makedirs(sequenceFold + s + i + s + 'data' + s + d)
for o in outFoldList:
os.makedirs(sequenceFold + s + i + s + 'out' + s + o)
shList = os.listdir(prPath + s + 'src' + s + i)
for sh in shList:
shFold = sequenceFold + s + i + s + 'shots'
os.makedirs(shFold + s + sh)
for f in shotFoldList:
os.makedirs(shFold + s + sh + s + f)
for ds in dataFoldList:
os.makedirs(shFold + s + sh + s + 'data' + s + ds)
for ot in outFoldList:
os.makedirs(shFold + s + sh + s + 'out' + s + ot)
shutil.move(prPath + s + 'src' + s + i + s + sh, shFold + s + sh + s + 'src')
os.system('ln -sf ' + shFold + s + sh + s + 'src ' + prPath + s + 'src' + s + i + s + sh)
示例5: __init__
def __init__(self, base_url, script_name, api_key, convert_datetimes_to_utc=True,
http_proxy=None, ensure_ascii=True, connect=True, host=None, port=None):
'''
We will initialize the Shotgun object, but will not connect right away.
Instead it will will attempt to create a socket connection using the
Shotgun object and the host and port data provided or generated. If we do
not have a host and port specified, or do not find a connection, we will
fall back and connect to the actual Shotgun server instead.
'''
Shotgun.__init__(self, base_url, script_name, api_key,
convert_datetimes_to_utc=convert_datetimes_to_utc,
http_proxy=http_proxy, ensure_ascii=ensure_ascii,
connect=False)
# If a host is not specified, attempt using the local machine.
if not host:
host = socket.gethostname()
# If a port is not specified, generate a port from the app key.
if not port:
port = common.appKeyToPort(self.config.api_key)
self._sgclient = None
self._host = host
self._port = port
if connect:
self.connect()
示例6: createProject
def createProject():
site = 'https://chimneypot.shotgunstudio.com'
scriptName = 'createProject'
scriptKey = '90699580e396b61d3acfb71e0595adde7458dfd4'
repo = '/mnt/karramba/'
rootList = ['film', 'out', 'ref', 'src', 'temp']
filmList = ['assets', 'sequences']
assetList = ['light', 'material', 'mattepaint', 'model', 'rig', 'shader', 'textures']
shotList = ['anim', 'comp', 'data', 'fx', 'light', 'out', 'src', 'tmp']
sqList = ['anim', 'comp', 'data', 'fx', 'light', 'out', 'shots']
dataList = ['cache', 'geo', 'render', 'shadowmap', 'sim', 'track', 'photonmap']
outList = ['dailies', 'hires']
prName = raw_input('Print project name:')
prPath = repo + prName
if not os.path.exists(prPath):
os.mkdir(prPath)
for i in rootList:
os.makedirs(prPath + os.sep + i)
for i in filmList:
os.makedirs(prPath + os.sep + 'film' + os.sep + i)
for i in assetList:
os.makedirs(prPath + os.sep + 'film' + os.sep + 'assets' + os.sep + i)
for i in outList:
os.makedirs(prPath + os.sep + 'out' + os.sep + i)
sg = Shotgun(site, scriptName, scriptKey)
sg.create('Project', {'name':prName})
示例7: _moveFilesToPublish
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"
示例8: _pubBttn
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
示例9: AppServerSvc
class AppServerSvc(win32serviceutil.ServiceFramework):
_svc_name_ = "timelog"
_svc_display_name_ = "shotgun time log"
def __init__(self, args):
win32serviceutil.ServiceFramework.__init__(self, args)
SetConsoleCtrlHandler(lambda x: True, True)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.count = 0
self.estinmins = 0
self.isAlive = True
self.envv = ""
self.prlist = []
def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
win32event.SetEvent(self.hWaitStop)
self.run = False
def SvcDoRun(self):
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, "")
)
self.sg = Shotgun(
"https://xxxxxxxxxxxxxxxx.shotgunstudio.com", "timelogservice", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
self.main()
def updateProject(self, projectid):
servicemanager.LogWarningMsg(unicode(projectid))
filters = [["project.Project.id", "is", projectid]]
fields = ["time_logs_sum", "est_in_mins"]
for eventTimeLog in self.sg.find("Task", filters, fields):
self.count = self.count + eventTimeLog["time_logs_sum"]
if eventTimeLog["est_in_mins"] is not None:
self.estinmins = self.estinmins + eventTimeLog["est_in_mins"]
data = {"sg_artisttimelog": self.count / 600}
asset = self.sg.update("Project", projectid, data)
data = {"sg_total_bid": self.estinmins / 600}
asset = self.sg.update("Project", projectid, data)
def main(self):
while self.isAlive:
filters = [["sg_status", "is", "active"]]
fields = ["id"]
for f in self.sg.find("Project", filters, fields):
self.prlist.append(f["id"])
for prid in self.prlist:
self.updateProject(prid)
self.count = 0
self.estinmins = 0
if win32event.WaitForSingleObject(self.hWaitStop, 3000) == win32event.WAIT_OBJECT_0:
break
示例10: connect
def connect(self):
'''
Attempts to connect to a Double Barrel Server first, then connects
directly to Shotgun if failed.
'''
# Attempt to open a socket at the host and port.
sgclient = DoubleBarrelClient(self, self.host(), self.port())
if sgclient.connect():
self._sgclient = sgclient
if not self._sgclient:
Shotgun.connect(self)
示例11: _get_projects_list
def _get_projects_list():
sg = Shotgun('http://yoursite.com', 'your_api', '123456')
filters = [['sg_status', 'is', 'Active'], ['tank_name', 'is_not', '']]
fields = ['name']
order = [{'field_name': 'name', 'direction': 'asc'}]
projectsDic = sg.find('Project', filters, fields, order)
newProjectsDic = []
for project in projectsDic:
newProjectsDic.append(project['name'].replace(' ', ''))
return newProjectsDic
示例12: __init__
def __init__(self):
sgSite = 'https://chimneypot.shotgunstudio.com'
scriptName = 'dBase'
scriptKey = '729a76955455909c79f6d90262bb9fbe9186b92b'
self.db = Shotgun(sgSite, scriptName, scriptKey)
示例13: SvcDoRun
def SvcDoRun(self):
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STARTED, (self._svc_name_, "")
)
self.sg = Shotgun(
"https://xxxxxxxxxxxxxxxx.shotgunstudio.com", "timelogservice", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
self.main()
示例14: getAllProjects
def getAllProjects():
site = 'https://chimneypot.shotgunstudio.com'
scriptName = 'AssetBrowser'
scriptKey = 'c35ab5f5322d4b1e8b6488bb315c03e5f38881ea'
sg = Shotgun(site, scriptName, scriptKey)
fields = ['id','name','type']
projects= sg.find("Project",[],fields)
if len(projects) < 1:
print "couldn't find any projects"
#exit(0)
else:
print "Found "+str(len(projects))+" projects"
# pprint (projects)
return projects
示例15: Button_Callback
def Button_Callback():
print ""+SCRIPT_NAME+" "+VERSION+"\n"
print "Connecting to %s..." % (SERVER_PATH),
sg = Shotgun(SERVER_PATH, SCRIPT_NAME, SCRIPT_KEY)
print "\n\nConnected\n\n"
# ---------------------------------------------------------------------------------------------
# Testing Block BEGIN
# ---------------------------------------------------------------------------------------------
result = sg.schema_entity_read()
pprint(result)
print ""+SERVER_PATH+"\n ... completed\n"
pass