本文整理汇总了Python中shotgun_api3.Shotgun._get_session_token方法的典型用法代码示例。如果您正苦于以下问题:Python Shotgun._get_session_token方法的具体用法?Python Shotgun._get_session_token怎么用?Python Shotgun._get_session_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shotgun_api3.Shotgun
的用法示例。
在下文中一共展示了Shotgun._get_session_token方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: legwork
# 需要导入模块: from shotgun_api3 import Shotgun [as 别名]
# 或者: from shotgun_api3.Shotgun import _get_session_token [as 别名]
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))
url = '%s/file_serve/attachment/%s' % (sg.base_url, entity_id)
request = urllib2.Request(url)
request.add_header('User-agent','Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.7) Gecko/2009021906 Firefox/3.0.7')
# Set result to a URL that can be accessed without a session cookie
result = urllib2.urlopen(request).geturl()
else:
print 'Unknown method: ' + method, sys.stderr