本文整理汇总了Python中sgtk.sgtk_from_path函数的典型用法代码示例。如果您正苦于以下问题:Python sgtk_from_path函数的具体用法?Python sgtk_from_path怎么用?Python sgtk_from_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sgtk_from_path函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:shotgunsoftware,项目名称:tk-core,代码行数:14,代码来源:test_pipelineconfig_factory.py
示例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)
开发者ID:adriankrupa,项目名称:tk-core,代码行数:15,代码来源:test_pipelineconfig_factory.py
示例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()
开发者ID:shotgunsoftware,项目名称:tk-nuke,代码行数:33,代码来源:__init__.py
示例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)
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:26,代码来源:app.py
示例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
开发者ID:whythisname,项目名称:shotgunEvents,代码行数:60,代码来源:subproc.py
示例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.')
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:25,代码来源:app.py
示例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)
开发者ID:shotgunsoftware,项目名称:tk-core,代码行数:16,代码来源:test_pipelineconfig_factory.py
示例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
开发者ID:hongloull,项目名称:tk-core,代码行数:30,代码来源:test_api.py
示例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)
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:7,代码来源:fetchEntityFromShotgun.py
示例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"])
开发者ID:shotgunsoftware,项目名称:tk-core,代码行数:16,代码来源:test_pipelineconfig_factory.py
示例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()
开发者ID:vipul-rathod,项目名称:lsapipeline,代码行数:60,代码来源:bbb_publishMayaAudioFiles.py
示例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)
开发者ID:adriankrupa,项目名称:tk-desktop,代码行数:25,代码来源:bootstrap_utilities.py
示例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
开发者ID:mds-dev,项目名称:mds_repository,代码行数:8,代码来源:MDSShotgun.py
示例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)
开发者ID:RichardTheStork,项目名称:wtd-multi-turntable,代码行数:8,代码来源:turntable.py
示例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.'
开发者ID:RichardTheStork,项目名称:tk-framework-wtd,代码行数:9,代码来源:assets.py
示例16: getDataFolder
def getDataFolder():
targetPath = getFileName()
tk = sgtk.sgtk_from_path(targetPath)
print targetPath
splitPath = targetPath.split("/")
print splitPath
name = getAssetName()
target = "%s/%s/%s/%s/%s/data/" %(splitPath[0],splitPath[1],splitPath[2],splitPath[3],name)
return target
开发者ID:RichardTheStork,项目名称:tk-multi-positionlistExport,代码行数:10,代码来源:app_B.py
示例17: set_publish_info
def set_publish_info():
try:
import sgtk
except:
shotgunErrorBox = libPySide.QCriticalBox()
shotgunErrorBox.setText("Shotgun toolkit not loaded")
shotgunErrorBox.setWindowTitle("Shotgun Module")
shotgunErrorBox.exec_()
return
# # Evaluate the path
path = pm.sceneName()
#
# # Get the toolkit
tk = sgtk.sgtk_from_path(path)
# # Get the nuke published area
nukePublishFolderTemplate = tk.templates['shot_publish_area_nuke']
#
# Deconstruct the maya scene
mayaTemplate = tk.template_from_path(path)
fields = mayaTemplate.get_fields(path)
nukePublishFolder = nukePublishFolderTemplate.apply_fields(fields)
#
publishNukeFile = [fileName for fileName in libFile.listfiles(nukePublishFolder) if fileName.endswith(".nk")]
currentPublishedNuke = libFile.search_pattern_in_folder(".nk", nukePublishFolder)
#
# increments the version
fields["version"] = len(publishNukeFile) + 1
# Get the maya scene file
mayaPublishFolderTemplate = tk.templates['maya_shot_render_folder']
mayaPublishVersion = "v%s" % str(fields["version"]).zfill(3)
mayaPublishVersionFolder = mayaPublishFolderTemplate.apply_fields(fields)
mayaShotTemplate = tk.templates['shot_publish_area_maya']
mayaProjectFolder = mayaShotTemplate.apply_fields(fields)
mayaFileName = "%s_%s" % (fields['Shot'], mayaPublishVersion)
renderer = pm.PyNode("defaultRenderGlobals")
renderer.currentRenderer.set("vray")
# Setup Vray
_set_vray_()
vraySettings = pm.PyNode("vraySettings")
vraySettings.fileNamePrefix.set(mayaFileName)
info = {"jobName": mayaFileName,
"imagesFolder": mayaPublishVersionFolder,
"projectFolder": mayaProjectFolder
}
# Set the meta data
set_render_meta_data(vraySettings, tk)
return info
开发者ID:mds-dev,项目名称:mds_repository,代码行数:53,代码来源:MDSShotgun.py
示例18: _import_script
def _import_script(self, new_script_path):
"""
Import contents of the given file into the scene.
:param path: Path to file.
:param sg_publish_data: Shotgun data dictionary with all the standard publish fields.
"""
# first we look at the current read nodes in the scene (they've been updated to their latest version already)
preloaded_nodes = nuke.allNodes('Read')
# We import the new nodes into the scene
# if not os.path.exists(new_path):
# raise Exception("File not found on disk - '%s'" % new_path)
nuke.nodePaste(new_script_path)
node = nuke.toNode('Published Data')
node['text'].setValue(new_script_path)
# Compare the new nodes with the old ones and delete the duplicates
new_nodes = [item for item in nuke.allNodes('Read') if item not in preloaded_nodes]
# Initialise the tank
tk = sgtk.sgtk_from_path(new_script_path)
# Get the maya render template
maya_render_template = tk.templates["maya_shot_render"]
cleanup_list = []
# Iterate through all the node
for new_node in new_nodes:
new_path = new_node['file'].value()
# Is it a published render
if maya_render_template.validate(new_path):
new_fields = maya_render_template.get_fields(new_path)
# Iterate through all the pre loaded node
for old_node in preloaded_nodes:
old_path = old_node['file'].value()
# Is it a published node
if maya_render_template.validate(old_path):
old_fields = maya_render_template.get_fields(old_path)
# Compare the fields
if (new_fields['Shot'] == old_fields['Shot']
and new_fields['render_layer'] == old_fields['render_layer']
and new_fields['version'] > old_fields['version']):
old_node["file"].setValue(new_path)
cleanup_list.append(new_node)
self.color_updated_read_node(old_node)
#Delete any redundents nodes
for node in list(set(cleanup_list)):
nuke.delete(node )
开发者ID:mds-dev,项目名称:mds_dev,代码行数:53,代码来源:tk-nuke_scene_operations.py
示例19: test_project_path_lookup
def test_project_path_lookup(self):
"""
Check that a sgtk init works for this path
"""
# only run this test on windows
if sys.platform == "win32":
# probe a path inside of project
test_path = "%s\\%s\\toolkit_test_path" % (self.STORAGE_ROOT, self.PROJECT_NAME)
if not os.path.exists(test_path):
os.makedirs(test_path)
self.assertIsInstance(sgtk.sgtk_from_path(test_path), Tank)
开发者ID:hongloull,项目名称:tk-core,代码行数:12,代码来源:test_api.py
示例20: sgtk_on_load_callback
def sgtk_on_load_callback():
try:
# If we have opened a file then we should check if automatic context switching is enabled and change if possible
engine = sgtk.platform.current_engine()
file_name = nuke.root().name()
if file_name != "Root" and engine is not None and engine.get_setting("automatic_context_switch"):
# We have a current script, and we have an engine and the current environment is set to
# automatic context switch, so we should attempt to change the context to suit the file that is open.
try:
# todo: do we need to create a new tk object, instead should we just check the context gets created correctly?
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
if sgtk.platform.current_engine():
curr_ctx = sgtk.platform.current_engine().context
new_ctx = tk.context_from_path(file_name, curr_ctx)
# Now switch to the context appropriate for the file
__engine_refresh(new_ctx)
elif file_name != "Root" and engine is None:
# we have no engine, this maybe because the integration disabled itself, due to a non Toolkit file being
# opened, prior to this new file. We must create a sgtk instance from the script path.
try:
tk = sgtk.sgtk_from_path(file_name)
except sgtk.TankError as e:
__create_tank_disabled_menu(e)
return
new_ctx = tk.context_from_path(file_name)
# Now switch to the context appropriate for the file
__engine_refresh(new_ctx)
except Exception:
__create_tank_error_menu()
开发者ID:shotgunsoftware,项目名称:tk-nuke,代码行数:40,代码来源:__init__.py
注:本文中的sgtk.sgtk_from_path函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论