Hi there,
I’m encountering an issue when trying to use the create_filesystem_structure()
function within the Shotgun Toolkit (SGTK) to create and register directories for an asset. Here’s a simplified version of my code:
mgr = sgtk.bootstrap.ToolkitManager()
mgr.base_configuration = DESCRIPTOR_STRING
sg_asset = tk.shotgun.find_one(“Asset”, [[“id”, “is”, 100]])
tk.create_filesystem_structure(“Asset”, sg_asset[“id”])
When running this code in several different Python environments, I get the following stack trace:
arduino
Traceback (most recent call last):
File “testscript.py”, line 48, in
tk.create_filesystem_structure(“Asset”, sg_asset[“id”])
File “…\cfg\install\core\python\tank\api.py”, line 916, in create_filesystem_structure
folders = folder.process_filesystem_structure(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “…\cfg\install\core\python\tank\folder\operations.py”, line 219, in process_filesystem_structure
folders_created = io_receiver.execute_folder_creation()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “…\cfg\install\core\python\tank\folder\folder_io.py”, line 131, in execute_folder_creation
rd = path_cache.synchronize()
^^^^^^^^^^^^^^^^^^^^^^^^
File “…\cfg\install\core\python\tank\path_cache.py”, line 360, in synchronize
return self._do_full_sync(c)
^^^^^^^^^^^^^^^^^^^^^
File “…\cfg\install\core\python\tank\path_cache.py”, line 639, in _do_full_sync
data = self._replay_folder_entities(cursor, max_event_log_id)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “…\cfg\install\core\python\tank\path_cache.py”, line 909, in _replay_folder_entities
sg_data = self._get_filesystem_location_entities(folder_ids=None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “…\cfg\install\core\python\tank\path_cache.py”, line 861, in _get_filesystem_location_entities
“Project id: %s” % project_entity[“id”]
~~~~~~~~~~~~~~^^^^^^
TypeError: ‘NoneType’ object is not subscriptable
It seems like there’s a problem with retrieving or processing the sg_asset
data, but I’m not sure how to fix it.
Here are my questions:
- Why is
project_entity
being returned asNone
when attempting to access theid
field, causing the'NoneType' object is not subscriptable
error? - What could be the underlying cause of this issue when calling
create_filesystem_structure()
after retrieving the asset usingtk.shotgun.find_one
? - How can I ensure that the asset is being correctly fetched from Shotgun before attempting to create the filesystem structure?
Any suggestions or insights would be greatly appreciated!
Best,
Regards
Darshan Hiranandani