To connect processors, add the processors section in the configuration file (see the Configuring section).
Element structure of processors:
{
"soft_name":
{
"open_pre":
{
"script_path": "path/to/script.py",
"function": "open_pre"
},
"open_replace":
{
"script_path": "path/to/script.py",
"function": "open_replace"
},
"open_post":
{
"script_path": "path/to/script.py",
"function": "open_post"
},
"new_pre":
{
"script_path": "path/to/script.py",
"function": "new_pre"
},
"new_replace":
{
"script_path": "path/to/script.py",
"function": "new_replace"
},
"new_post":
{
"script_path": "path/to/script.py",
"function": "new_post"
},
"link_pre":
{
"script_path": "path/to/script.py",
"function": "link_pre"
},
"link_replace":
{
"script_path": "path/to/script.py",
"function": "link_replace"
},
"link_post":
{
"script_path": "path/to/script.py",
"function": "link_post"
},
"embed_pre":
{
"script_path": "path/to/script.py",
"function": "embed_pre"
},
"embed_replace":
{
"script_path": "path/to/script.py",
"function": "embed_replace"
},
"embed_post":
{
"script_path": "path/to/script.py",
"function": "embed_post"
},
"check_reference_pre":
{
"script_path": "path/to/script.py",
"function": "check_reference_pre"
},
"check_reference_replace":
{
"script_path": "path/to/script.py",
"function": "check_reference_replace"
},
"check_reference_post":
{
"script_path": "path/to/script.py",
"function": "check_reference_post"
},
"reload_reference_pre":
{
"script_path": "path/to/script.py",
"function": "reload_reference_pre"
},
"reload_reference_replace":
{
"script_path": "path/to/script.py",
"function": "reload_reference_replace"
},
"reload_reference_post":
{
"script_path": "path/to/script.py",
"function": "reload_reference_post"
},
"version_pre":
{
"script_path": "path/to/script.py",
"function": "version_pre"
},
"version_replace":
{
"script_path": "path/to/script.py",
"function": "version_post"
},
"publish_pre":
{
"script_path": "path/to/script.py",
"function": "publish_pre"
},
"publish_replace":
{
"script_path": "path/to/script.py",
"function": "publish_replace"
},
"publish_post":
{
"script_path": "path/to/script.py",
"function": "publish_post"
},
"link_pre":
{
"script_path": "path/to/script.py",
"function": "link_pre"
},
"link_replace":
{
"script_path": "path/to/script.py",
"function": "link_replace"
},
"link_post":
{
"script_path": "path/to/script.py",
"function": "link_post"
},
"embed_pre":
{
"script_path": "path/to/script.py",
"function": "embed_pre"
},
"embed_replace":
{
"script_path": "path/to/script.py",
"function": "embed_replace"
},
"embed_post":
{
"script_path": "path/to/script.py",
"function": "embed_post"
},
"indicator_task":
{
"script_path": "path/to/script.py",
"function": "indicator_task"
},
"menu_task":
{
"script_path": "path/to/script.py",
"function": "menu_task"
},
"menu_file":
{
"script_path": "path/to/script.py",
"function": "menu_file"
}
}
}
Key soft_name
The internal name of one of the supported applications, for example maya, nuke, houdini, blender, cinema4d, 3dsmax etc.
Variable script_path
Specifies the full path to the Python script. A path variable can contain environment variables as well as a specific variable $(cerebro_plugins).
$(cerebro_plugins) - defines the path to the folder of Cerebro plugins that are delivered using the built-in plugin distribution system. This way you can load processors as Cerebro plugins and they will be used in Tentaculo.
Variable function
The name of the called function. The called function must take two dictionary parameters as arguments and return the second one, modified if necessary.
The first argument is a dictionary, which is common to all processors, and contains the following keys:
task_id - task ID;
task_name - task name;
task_parent_id - parent task ID;
task_parent_path - Cerebro parent task path ;
task_status_id - current task status ID;
task_status_name - name of the current task status;
task_activity_id - activity ID of the task;
task_activity_name - task activity name;
task_unid - universe ID of the task;
current_user_id - current user ID;
current_user_name - current user's display name.
The second argument is processor specific.
Creating a new file
Processors to create a new file are called when starting work with a task in which there are no versions yet, i.e. an empty file is created.
new_pre
- called just before the creation of the file;
new_replace
- called instead of the standard file creation procedure;
new_post
- called immediately after the file creation procedure.
{
"local_file_path": "", # full path to the working version of the file
"original_file_path": "", # full path to the original version of the file
"review": false, # variable indicating what the file is being opened for. false - start to work, true - review
}
Opening a file
File open processors are called to open an existing version in a task, through the Start working and Open to review (safe mode) menu items. The Open to view item does not call processors.
open_pre
- Called just before opening the file;
open_replace
- Called instead of the standard file opening procedure;
open_post
- Called immediately after the file open procedure.
{
"local_file_path": "", # full path to the working version of the file
"original_file_path": "" # full path to the original version of the file
}
If you need to change any key, you must replace the value of that key (s) and return an argument.
For example, you want to replace the original version for a task named test with some other file to open it instead of the one selected by the user.
For this you need to write a processor open_pre:
def open_pre(task_info, arg):
if task_info['name'] == 'test':
arg['original_file_path'] = 'C:/test_file.ma'
return arg
Save version
Save a numbered version of a file. The version save processors are called to save the version and publish the report.
version_pre
- Called just before saving the version;
version_replace
- It is called instead of the standard procedure for saving a version and publishing a report;
version_post
- Called immediately after the procedure for saving a version and publishing a report.
{
"local_file_path": "", # full path to the working version of the file
"version_file_path": "", # full path to the saved version of the file
"report":
{
"plain_text": "", # report text
"work_time": "" # work time in minutes
},
"attachments": # set of files attached to the report via Cargador
{
"file_path": [paths to file thumbnails], # file_path - path to file
...
},
"links": # a set of files attached to the report by a link
{
"file_path": [paths to file thumbnails],
...
},
"new_status_id" : "", # ID of the new task status, the None value means the task status is not to be switched
"screenshot": "", # the path to the version's thumbnail
"send_version": True # defines whether the version file needs to be attached to the report in Cerebro
}
Note:
The Tentaculo provides for saving the version without publishing the report, in this case the value "report": {}, "attachments": {}, "links": {} will be empty.
If you need to change any key, you must replace the value of that key (s) and return an argument.
(insert as code)
arg['report']['plain_text'] += ' Path to file ' + arg['version_file_path']
return arg
File publishing
Saving the main version of the file. When publishing, usually, a file version with a number and a major version without a number are created.
Processors are called for file publication with a report.
publish_pre
- Called just before the file is published.
publish_replace
- Called instead of the regular file publishing and report publishing procedure.
publish_post
- Called immediately after the procedure for publishing a file and publishing a report.
{
"local_file_path": "", # full path to the working version of the file
"version_file_path": "", # full path to the saved version of the file
"publish_file_path": "", # full path to the published final (main) file
"report":
{
"plain_text": "", # report text
"work_time": "" # work time in minutes
},
"attachments": # set of files attached to the report via Cargador
{
"file_path": [paths to file thumbnails], # file_path - path to file
...
},
"links": # a set of files attached to the report by a link
{
"file_path": [paths to file thumbnails],
...
}
}
If you need to change any key, you must replace the value of that key (s) and return an argument.
arg['attachments'].setdefault("c:\image.png", [])
return arg
Extending the task menu
The processor is called when the user opens the context menu of a task in the ToDo list and allows you to add your own items to this menu.
menu_task
- Called before showing the task context menu to the user. The second argument for the processor is a dictionary:
{
"option_list":
[
{"text": "Open in Cerebro...", "index": 0},
{"text": None, "index": 1},
{"text": "Copy local path to Clipboard", "index": 2},
{"text": "Show in Explorer...", "index": 3}
]
}
'option_list' - contains a list of standard items of the task menu, with the indices of their positions in the menu.
'text' - item name. If there is no name, the item is considered a separator (separator in the menu).
The return value for this processor should contain a list of dictionaries for the menu items to be embedded:
[
{
"text": "", # menu item name
"index": 0, # index of the position in the menu
"script_path": "", # path to Python script
"function": "" # the name of the called function to trigger the menu item
},
...
]
The function specified in "function" takes two arguments.
The first argument is a dictionary with information on the selected task, the same as in the processor.
The second argument is a dictionary:
{
'option_list':
[
# full list of menu items
]
, 'option': "" # name of the selected menu item
}
For example, you need a menu item that displays the full path to a task.
def menu_task(task_info, arg):
my_action = {}
my_action.setdefault('text', 'My Action - print task path')
my_action.setdefault('index', len(arg['option_list']))
my_action.setdefault('script_path', os.path.abspath(__file__))
my_action.setdefault('function', 'my_action')
return [my_action,]
# function called when clicking on a menu item "My Action - print task path"
def my_action(task_info, arg):
print('Task Path {0}/{1}'.format(task_info['task_parent_path'], task_info['task_name']))
File menu extension
The processor is called when the user opens the context menu of the file in the selected task and allows you to add your own items to this menu.
menu_file - Called before showing the file's context menu to the user.
{
"file_path" "", # полный путь до выбранного файла
"option_list":
[
{"text": "Start working on this file", "index": 0},
{"text": "Open without Starting the Task", "index": 1},
{"text": None, "index": 2},
{"text": "Link", "index": 3},
{"text": "Embed", "index": 4},
{"text": None, "index": 5},
{"text": "Show in Explorer...", "index": 6},
{"text": "Copy file path to Clipboard", "index": 7}
],
}
'option_list' - contains a list of standard file menu items, with their indexes in the menu. 'text' - item name. If there is no name, the item is considered a separator (separator in the menu).
The return value for this processor should contain a list of dictionaries for the menu items to be embedded:
[
{
"text": "", # menu item name
"index": 0, # index of the position in the menu
"script_path": "", # path to Python script
"function": "" # the name of the called function to trigger the menu item
},
...
]
The function specified in "function" takes two arguments.
The first argument is a dictionary with information on the selected task, the same as in the processor.
The second argument is a dictionary:
{
'option_list' :
[
# full list of menu items
]
, 'option': "" # name of the selected menu item
, 'file_path': "" # full path to the selected file
}
For example, you need a menu item that displays the full path to a file.
def menu_file(task_info, arg):
my_action = {}
my_action.setdefault('text', 'My Action - print file path')
my_action.setdefault('index', len(arg['option_list']))
my_action.setdefault('script_path', os.path.abspath(__file__.replace('.pyc', '.py')))
my_action.setdefault(function, 'my_action_file')
return [my_action,]
# function called when clicking on the "My Action - print file path" menu item
def my_action_file(task_info, arg):
print('File Path {0}'.format(arg['file_path']))
Color indication of tasks
The processor is called when each of the tasks is displayed in the ToDo sheet and allows you to assign a color to it a color.
indicator_task
- Called to render the task in the interface.
The second argument is a string:
task_hex - task color in HEX format
task_hex always comes with a value of None. To specify a color indicator, you must specify a HEX color as the return value.
def indicator_task(task_info, arg):
return "white" if task_info["task_name"] == "animation" else "green"
Task Search
The processor is activated when a user enters text in the task browser's search bar and presses the Enter key.
The second argument is a dictionary containing:
{
'projects_set':
{
# a set of project identifiers where the search will be conducted
}
, 'query': "" # The search string
}
In the processor, you can modify the text entered by the user or alter the set of projects to be included in the task search.
For example, to expedite scene searches by number, you can agree with the user that they only need to enter the scene number for the search. The processor will then automatically append the rest of the name.
def search_task(task_info, arg):
if arg["query"].isdigit():
arg["query"] = "scene_" + arg["query"]
return arg
Note: The search will be performed across the entire task path.
Screenshot for Version Publication
When publishing a version in Cerebro, a screenshot is attached to the file as a thumbnail.
Processors:
screenshot_pre
- Called right before capturing a screenshot;
screenshot_replace
- Called as an alternative to capturing a screenshot;
screenshot_post
- Called immediately after the screenshot procedure for version publication.