本文整理汇总了Python中sgtk.sgtk_from_path函数的典型用法代码示例。如果您正苦于以下问题:Python sgtk_from_path函数的具体用法?Python sgtk_from_path怎么用?Python sgtk_from_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sgtk_from_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_no_primary
def test_no_primary(self):
"""
Ensures error is raised if there are no primary available.
"""
self.mockgun.update(
"PipelineConfiguration",
self.pipeline_configuration.get_shotgun_id(),
{"code": "Secondary"}
)
with self.assertRaisesRegex(
TankInitError,
"does not have a Primary pipeline configuration!"
):
sgtk.sgtk_from_path(self.project_root)
示例2: test_no_path
def test_no_path(self):
"""
Ensures error is raised if the primary has no path set.
"""
self.mockgun.update(
"PipelineConfiguration",
self.pipeline_configuration.get_shotgun_id(),
{"windows_path": None, "linux_path": None, "mac_path": None}
)
# We do not support site-wide pipeline configurations from shared cores.
with self.assertRaisesRegexp(
TankInitError,
"cannot be instantiated because it does not have an absolute path"
):
sgtk.sgtk_from_path(self.project_root)
示例3: __sgtk_on_save_callback
def __sgtk_on_save_callback():
"""
Callback that fires every time a file is saved.
Carefully manage exceptions here so that a bug in Tank never
interrupts the normal workflows in Nuke.
"""
# get the new file name
file_name = nuke.root().name()
try:
# this file could be in another project altogether, so create a new Tank
# API instance.
try:
tk = sgtk.sgtk_from_path(file_name)
except sgtk.TankError as e:
__create_tank_disabled_menu(e)
return
# try to get current ctx and inherit its values if possible
curr_ctx = None
curr_engine = sgtk.platform.current_engine()
if curr_engine:
curr_ctx = curr_engine.context
# and now extract a new context based on the file
new_ctx = tk.context_from_path(file_name, curr_ctx)
# now restart the engine with the new context
__engine_refresh(new_ctx)
except Exception:
__create_tank_error_menu()
示例4: __init__
def __init__(self, app):
"""
"""
QtGui.QWidget.__init__(self)
self.app = app
# debug(self.app, method = 'MainUI.__init__', message = 'Running app...', verbose = False)
self.context = self.app.context ## To get the step
# debug(app = self.app, method = 'MainUI.__init__', message = 'context: %s' % self.context, verbose = False)
if self.context.step['name'] == 'Blocking':
self.tk = sgtk.sgtk_from_path("T:/software/bubblebathbay")
################### UI LOAD / BUILD NOW
## Now build the UI
self.mainLayout = QtGui.QVBoxLayout(self)
## Setup the layout and buttons
self.buttonLayout = QtGui.QHBoxLayout()
self.shotBasedSBoardButton = QtGui.QPushButton('Fetch StoryBoard')
self.shotBasedSBoardButton.clicked.connect(self._singleShotSBoard)
## Add the buttons to their layout widget
self.buttonLayout.addWidget(self.shotBasedSBoardButton)
self.mainLayout.addLayout(self.buttonLayout)
self.mainLayout.addStretch(1)
self.resize(300, 20)
示例5: publishingSubProc
def publishingSubProc(winpath, vpath, vcode, eventID, linkType, linkID, taskID):
# Get toolkit engine (sgtk) of the project
sys.path.append('%s/install/core/python' % winpath)
import sgtk
sys.path.remove('%s/install/core/python' % winpath)
#f, filename, desc = imp.find_module('sgtk', ['%s/install/core/python/' % winpath])
#sgtk = imp.load_module('sgtk', f, filename, desc)
# Publish the version
# Get toolkit
tk = sgtk.sgtk_from_path(vpath)
tk.synchronize_filesystem_structure()
# Set context
ctx = tk.context_from_entity(linkType,linkID)
#print(ctx)
# Construct path to facilis, this is where the renders have to be copied to and needs to be put in the publish
# Get the template to the rendered frames
version_path_template = tk.templates['maya_render_shot_version']
# Get field data from vpath with the use of the template
fields = version_path_template.get_fields(vpath.replace("\\","/"))
# Get the template location of where to copy the frames to
publish_path_template = tk.templates['maya_render_shot_publish']
# Apply the field data to the "publish" template and remove the file name because we only need the destination directory for copying purposes
facilis_dir_path = publish_path_template.parent.apply_fields(fields)
# Apply the field data to the entire template as well, for publishing after the file copying
publish_location = publish_path_template.apply_fields(fields)
# Check if path to copy to exists, if not -> create it
# @TODO: what if the folder exists and has files in it, overwrite? abort?
if not os.path.exists(facilis_dir_path):
os.makedirs(facilis_dir_path)
# Start copy and rename loop
for frame in glob.glob(vpath.replace("#", "?")):
# First, copy the file to the new destination, this is the easy part
#print(frame)
#print(facilis_dir_path)
shutil.copy(frame, facilis_dir_path)
# Second, rename the file to fit the publish template
# To do that first we get the name of the file we just copied and append it to the path we copied to.
# That way we get the complete path + file name so we know what to rename and where it is located
old_file = os.path.split(frame)[1]
rename_from_file = os.path.join(facilis_dir_path, old_file)
# Next get the fields from the version template, this is done here because only now the file has the frame number in its name
# Unlike before where it was just ####
fields = version_path_template.get_fields(frame)
# Apply the fields to the publishing template to figure out to what to rename the file
rename_to_file = publish_path_template.apply_fields(fields)
# Do the actual renaming if the file names don't match
if rename_from_file != rename_to_file:
os.rename(rename_from_file, rename_to_file)
# Register the publish
published_entity = sgtk.util.register_publish(tk, ctx, publish_location, vcode, fields['version'], published_file_type='Rendered Image', version_entity={"type":"Version", "id":eventID}, task={"type":"Task", "id":taskID})
return published_entity
示例6: run_app
def run_app(self):
"""
Callback from when the menu is clicked.
"""
context = self.context ## To get the step
debug(app = self, method = 'run_app', message = 'Context Step...\n%s' % context.step['name'], verbose = False)
if context.step['name'] == 'Surface':
## Tell the artist to be patient... eg not genY
inprogressBar = pbui.ProgressBarUI(title = 'Building Asset Shaders:')
inprogressBar.show()
inprogressBar.updateProgress(percent = 5, doingWhat = 'Processing scene info...')
## Instantiate the API
tk = sgtk.sgtk_from_path("T:/software/bubblebathbay")
debug(app = self, method = 'run_app', message = 'API instanced...\n%s' % tk, verbose = False)
debug(app = self, method = 'run_app', message = 'RebuildLIBSHD launched...', verbose = False)
## Now process XML
debug(app = self, method = 'processTemplates', message = 'Looking for LIB assets to rebuild now', verbose = False)
shd.reconnectLIBSHD(rootGrp = 'geo_hrc', freshImport = False)
inprogressBar.updateProgress(percent = 100, doingWhat = 'COMPLETE...')
inprogressBar.close()
inprogressBar = None
else:
cmds.warning('Not a valid SRF context step. Try making sure you are in a valid Surfacing step launched from shotgun.')
示例7: test_no_path
def test_no_path(self):
"""
Ensures error is raised if the primary has no path set.
"""
self.mockgun.update(
"PipelineConfiguration",
self.pipeline_configuration.get_shotgun_id(),
{"windows_path": None, "linux_path": None, "mac_path": None}
)
# We do not support site-wide pipeline configurations from shared cores.
with self.assertRaisesRegex(
TankInitError,
"cannot be instantiated because it is a distributed config. "
"To launch this kind of configuration, use the Bootstrap API instead."
):
sgtk.sgtk_from_path(self.project_root)
示例8: test_project_path_lookup_local_mode
def test_project_path_lookup_local_mode(self):
"""
Check that a sgtk init works for this path
"""
# By setting the TANK_CURRENT_PC, we emulate the behaviour
# of a local API running. Push this variable
old_tank_current_pc = None
if "TANK_CURRENT_PC" in os.environ:
old_tank_current_pc = os.environ["TANK_CURRENT_PC"]
os.environ["TANK_CURRENT_PC"] = self.pipeline_config_root
probe_path = {}
probe_path["win32"] = "C:\\temp\\foo\\bar\\test.ma"
probe_path["darwin"] = "/tmp/foo/bar/test.ma"
probe_path["linux2"] = "/tmp/foo/bar/test.ma"
test_path = probe_path[sys.platform]
test_path_dir = os.path.dirname(test_path)
if not os.path.exists(test_path_dir):
os.makedirs(test_path_dir)
self.assertIsInstance(sgtk.sgtk_from_path(test_path), Tank)
# and pop the modification
if old_tank_current_pc is None:
del os.environ["TANK_CURRENT_PC"]
else:
os.environ["TANK_CURRENT_PC"] = old_tank_current_pc
示例9: __init__
def __init__(self):
self.tk = sgtk.sgtk_from_path('T:/software/lsapipeline')
fields = ['image', 'code', 'id', 'description']
projectId = 113
databasePath = 'T:/software/lsapipeline/install/apps/tk-custom-workfiles/python/tk_custom_workfiles/database/'
self.getAssetList(projectId, fields, databasePath)
self.getShotList(projectId, fields, databasePath)
示例10: test_multiple_primaries
def test_multiple_primaries(self):
"""
Ensures that a site-level primary is not considered for a shared-core for a project.
"""
self.mockgun.create(
"PipelineConfiguration",
{
"code": "Primary",
"mac_path": "/a/b/c",
"windows_path": "C:\\b\\a",
"linux_path": "/a/b/c"
}
)
sgtk.sgtk_from_path(self.project_root)
sgtk.sgtk_from_entity(self.project["type"], self.project["id"])
示例11: _publishAudio
def _publishAudio(self):
"""
Function to add the publish a maya audio file both making a maya file with an audio node and publishing this to shotgun as a version
"""
for key, var in self.fileBoxes.items():
if var:
if key.isChecked():
## Work out what we need for the creation of the ma file
## and the publish for shotgun
self.pathToWav = var
if sys.platform == 'win32':
self.publishPath = var.replace('/publish/wav', '/publish/maya').replace('.wav', '.ma').replace('/', '\\')
self.localPath = self.publishPath.split('I:')[-1]
self.localPathMac = self.publishPath.replace('I:', '/_projects')
self.fileName = str(key.text()).replace('.wav', '.ma')
self.wavName = str(key.text())
self.wavSGName = str(key.text().replace('_AUD', '').split('.')[0])
self.version_number = int(str(key.text()).split('.')[-2].split('v')[-1])
## Now register the publish with Shotgun
## First find the audio on shotgun for processing.
self.exists = self.sgsrv.find_one('CustomEntity03', filters = [["code", "is", self.wavSGName]], fields=['code', 'tasks', 'id'])
if not self.exists:
print '%s has no shotgun entry! You should make sure this has been processed correctly before proceeding!!' % self.wavName
else:
## now publish
tk = sgtk.sgtk_from_path("I:/lsapipeline/")
ctx = tk.context_from_path(self.publishPath)
## For existing check
## CHECK FOR EXISTING PUBLISH WITH THE SAME VERSION NUMBER!!!!
findExisting = self.sgsrv.find_one('PublishedFile', filters = [["code", "is", self.wavSGName]], fields=['code', 'id', 'version_number', 'created_at', 'entity'])
if findExisting:
if findExisting['version_number'] == self.version_number:
print 'A PUBLISHED FILE FOR THIS VERSION ALREADY EXISTS SKIPPING! VERSION UP OR DELETE EXISTING SHOTGUN PUBLISH ENTRIES IF YOU NEED TO YOU SHOULDNT BUT YOU MIGHT!'
## WRITE THE MA
## Now write the ma file we are going to publish with the audio node created.
## Note this will delete and re-make any ma files with the same name in the folder if they exist
self._writeMaFile(self.fileName, self.pathToWav, self.wavName, self.publishPath)
else:## This is a new version number
## WRITE THE MA
## Now write the ma file we are going to publish with the audio node created.
## Note this will delete and re-make any ma files with the same name in the folder if they exist
self._writeMaFile(self.fileName, self.pathToWav, self.wavName, self.publishPath)
self._createPublish(publishPath = self.publishPath, fileName = self.fileName, pathToWav = self.pathToWav, wavName = self.wavName, version_number = self.version_number,
localPath = self.localPath, localPathMac = self.localPathMac, wavSGName = self.wavSGName, ctx = ctx)
else:## nothing already exists so build a fresh publish
## WRITE THE MA
## Now write the ma file we are going to publish with the audio node created.
## Note this will delete and re-make any ma files with the same name in the folder if they exist
self._writeMaFile(self.fileName, self.pathToWav, self.wavName, self.publishPath)
self._createPublish(publishPath = self.publishPath, fileName = self.fileName, pathToWav = self.pathToWav, wavName = self.wavName, version_number = self.version_number,
localPath = self.localPath, localPathMac = self.localPathMac, wavSGName = self.wavSGName, ctx = ctx)
print 'Complete'
self.goButton.setText('COMPLETE.. click to run again')
self.goButton.setStyleSheet('QPushButton {background-color: green; border: 2px solid 1 ; border-radius: 6px;}')
self.repaint()
示例12: start_engine
def start_engine(data):
"""
Start the tk-desktop engine given a data dictionary like the one passed
to the launch_python hook.
"""
sys.path.append(data["core_python_path"])
# make sure we don't inherit the GUI's pipeline configuration
os.environ["TANK_CURRENT_PC"] = data["config_path"]
import sgtk
sgtk.util.append_path_to_env_var("PYTHONPATH", data["core_python_path"])
# If the core supports the shotgun_authentication module and the pickle has
# a current user, we have to set the authenticated user.
if hasattr(sgtk, "set_authenticated_user"):
# Retrieve the currently authenticated user for this process.
from tank_vendor.shotgun_authentication import ShotgunAuthenticator
user = ShotgunAuthenticator(sgtk.util.CoreDefaultsManager()).get_default_user()
sgtk.set_authenticated_user(user)
tk = sgtk.sgtk_from_path(data["config_path"])
tk._desktop_data = data["proxy_data"]
ctx = tk.context_from_entity("Project", data["project"]["id"])
return sgtk.platform.start_engine("tk-desktop", tk, ctx)
示例13: _get_shotgun_fields_from_file_name_
def _get_shotgun_fields_from_file_name_():
import sgtk
libUtilities.pyLog.info('Getting info from Shotgun')
path = pm.sceneName()
tk = sgtk.sgtk_from_path(path)
template_obj = tk.template_from_path(path)
fields = template_obj.get_fields(path)
return template_obj, fields, tk
示例14: getTank
def getTank():
if _platform == "win32":
ProjectPath= "W:\WG\Shotgun_Configs\RTS_Master"
elif _platform == "linux" or _platform == "linux2":
ProjectPath="/srv/projects/rts/WG/Shotgun_Configs/RTS_Master"
else:
ProjectPath= "W:/WG/Shotgun_Configs/RTS_Master"
return sgtk.sgtk_from_path(ProjectPath)
示例15: __init__
def __init__(self, projectPath = None, sgtk = None):
if sgtk != None:
self.tk = sgtk
return
if projectPath != None:
self.projectPath = projectPath
self.tk = sgtk.sgtk_from_path(self.projectPath)
print 'Initialize Done.'