### Create Tasks and Hierarchies (Python) Source: https://context7.com/cerebrohq/integration/llms.txt Adds new tasks to a project structure and assigns them an activity type. This code retrieves root tasks, gets available activities, creates a new task under a specified parent, and adds a definition message to notify assigned users. Requires the `ctentaculo.pycerebro` module. ```python from ctentaculo.pycerebro import database, dbtypes db = database.Database() db.connect('username', 'password') # Get root tasks (top-level projects) root_tasks = db.root_tasks() parent_id = root_tasks[0][dbtypes.TASK_DATA_ID] # Get available activities activities = db.activities() modeling_activity_id = None for activity in activities: if activity[dbtypes.ACTIVITY_DATA_NAME] == "Modeling": modeling_activity_id = activity[dbtypes.ACTIVITY_DATA_ID] break # Create new task under parent new_task_id = db.add_task( parent_id=parent_id, name="Character Model v1", activity_id=modeling_activity_id or 0 ) # Create definition message to notify assigned users definition_id = db.add_definition( task_id=new_task_id, html_text="

Please create character model based on concept art

" ) print(f"Created task ID: {new_task_id} with definition {definition_id}") ``` -------------------------------- ### Install, Update, and Uninstall Tentaculo Plugin in Python Source: https://context7.com/cerebrohq/integration/llms.txt This Python code utilizes the ctentaculo.install module to manage the Tentaculo plugin for various graphics applications. It supports installation, updating, uninstallation, retrieving the previous version, and getting the installed path. The installer automatically detects compatible software. ```python from ctentaculo import install # Launch installer GUI # Automatically detects installed software: # - Maya, 3ds Max, Nuke, Houdini, Blender # - Cinema 4D, AutoCAD, Revit, Katana # - Adobe Creative Suite (Photoshop, After Effects, etc.) install.install() # Update existing installation install.update() # Uninstall plugin install.uninstall() # Get previous installation version prev_version = install.getPrevVersion() print(f"Previous version: {prev_version[1]}") # Get installed path installed_path = install.installed_path() print(f"Installation directory: {installed_path}") ``` -------------------------------- ### Update Task Properties (Python) Source: https://context7.com/cerebrohq/integration/llms.txt Modifies various task attributes such as status, priority, progress, planned time, start date, and finish date. It retrieves task statuses, sets the task status to 'In Progress', and updates other properties. Requires the `ctentaculo.pycerebro` module and `datetime`. ```python from ctentaculo.pycerebro import database, dbtypes import datetime db = database.Database() db.connect('username', 'password') task_id = 12345 # Set task status statuses = db.statuses() in_progress_status = None for status in statuses: if "In Progress" in status[dbtypes.STATUS_DATA_NAME]: in_progress_status = status[dbtypes.STATUS_DATA_ID] break if in_progress_status: db.task_set_status(task_id, in_progress_status) # Set priority to high db.task_set_priority(task_id, dbtypes.TASK_PRIORITY_HIGH) # Update progress percentage db.task_set_progress(task_id, 45) # Set planned working time (40 hours) db.task_set_planned_time(task_id, 40.0) # Set start date to today datetime_now = datetime.datetime.utcnow() datetime_2000 = datetime.datetime(2000, 1, 1) days_from_2000 = (datetime_now - datetime_2000).total_seconds() / (24*60*60) db.task_set_start(task_id, days_from_2000) # Set finish date 7 days ahead db.task_set_finish(task_id, days_from_2000 + 7) print(f"Task {task_id} updated successfully") ``` -------------------------------- ### Configure Paths and Translate Tasks to Filesystem in Python Source: https://context7.com/cerebrohq/integration/llms.txt This Python script configures project paths and translates task structures into filesystem paths using tentaculo.core.config and tentaculo.api.icerebro.db. It requires an active database connection and a task ID. The output includes version, publish, local paths, and task validity checks. ```python from tentaculo.core import config from tentaculo.api.icerebro import db # Initialize connection and config conn = db.Db() conn.autologin() conf = config.Config() # Get task data task_id = 12345 task = conn.task(task_id) # Translate task to filesystem paths task_paths = conf.translate(task) print(f"Version path: {task_paths['version']}") print(f"Publish path: {task_paths['publish']}") print(f"Local path: {task_paths['local']}") print(f"File name: {task_paths['name']}") print(f"Name editable: {task['name_editable']}") print(f"Task valid: {task['valid_task']}") # Check if task can be used for file operations is_valid = conf.task_valid(task) if is_valid[0]: # valid_task print(f"Task is ready for file operations") elif is_valid[1]: # valid_parent print(f"Task is parent container - select child task") else: print(f"Task path configuration incomplete") ``` -------------------------------- ### Attach Files to Messages via Cargador Source: https://context7.com/cerebrohq/integration/llms.txt This script illustrates how to attach files to a message within a task. It covers both uploading files to Cargador storage (with optional thumbnails) and creating a reference link to an external network file. It requires `database`, `cargador`, and `dbtypes` from `ctentaculo.pycerebro`, along with the `os` module. The `as_link` parameter controls whether the file is uploaded or linked. ```python from ctentaculo.pycerebro import database, cargador import os db = database.Database() db.connect('username', 'password') # Initialize Cargador file manager carga = cargador.Cargador() carga.login('username', 'password') task_id = 12345 message_id = db.add_review(task_id, None, "

Render preview attached

", 30) # Attach file physically (uploads to storage) file_path = "/path/to/render_v001.exr" thumbnails = ["/path/to/thumb1.jpg", "/path/to/thumb2.jpg"] attachment_id = db.add_attachment( message_id=message_id, carga=carga, filename=file_path, thumbnails=thumbnails, description="First render pass - lighting test", as_link=False, # Upload file to storage path='' ) # Attach as link (reference external file) network_file = "//server/projects/project1/assets/model.ma" link_id = db.add_attachment( message_id=message_id, carga=None, # Not needed for links filename=network_file, thumbnails=None, description="Source Maya file", as_link=True, # Create link reference path='' ) # Get message attachments attachments = db.message_attachments(message_id) for att in attachments: att_name = att[dbtypes.ATTACHMENT_DATA_FILE_NAME] att_tag = att[dbtypes.ATTACHMENT_DATA_TAG] print(f"Attachment: {att_name} (tag: {att_tag})") ``` -------------------------------- ### Create Directory Structures for Tasks in Python Source: https://context7.com/cerebrohq/integration/llms.txt This Python script automatically creates folder hierarchies for tasks using tentaculo.browse, tentaculo.api.icerebro.db, and tentaculo.core.config. It connects to the database, translates task data to paths, and creates predefined subdirectories like 'scenes', 'renders', and 'cache' if they don't exist. Task IDs can be specified or obtained from the Cerebro client context. ```python from ctentaculo import browse from tentaculo.api.icerebro import db from tentaculo.core import config import os # Connect to database conn = db.Db() conn.autologin() conf = config.Config() # Get selected tasks (in Cerebro client context) # In standalone mode, specify task IDs task_ids = [12345, 12346, 12347] for task_id in task_ids: task = conn.task(task_id) task_paths = conf.translate(task) # Create directory structure paths_to_create = ['version', 'publish', 'local'] for path_key in paths_to_create: path = task_paths.get(path_key, None) if path and not os.path.exists(path): os.makedirs(path) print(f"Created: {path}") # Create subdirectories based on browse_config.json # e.g., /scenes, /renders, /cache, /textures subdirs = ['scenes', 'renders', 'cache', 'textures', 'references'] for subdir in subdirs: full_path = os.path.join(path, subdir) if not os.path.exists(full_path): os.makedirs(full_path) print(f"Directory structure created for {len(task_ids)} tasks") ``` -------------------------------- ### Manage Task Tags Source: https://context7.com/cerebrohq/integration/llms.txt This script demonstrates how to manage custom metadata tags on tasks. It includes fetching available tags for a project, setting enum, string, and integer values for specific tags on a task, and retrieving the currently assigned tag values for a task. Dependencies include `database`, `dbtypes` from `ctentaculo.pycerebro`. ```python from ctentaculo.pycerebro import database, dbtypes db = database.Database() db.connect('username', 'password') task_id = 12345 project_id = db.task(task_id)[dbtypes.TASK_DATA_PROJECT_ID] # Get available tags for project tags = db.project_tags(project_id) tag_char_type = None tag_render_engine = None tag_poly_count = None for tag in tags: tag_name = tag[dbtypes.TAG_DATA_NAME] tag_id = tag[dbtypes.TAG_DATA_ID] tag_type = tag[dbtypes.TAG_DATA_TYPE] if tag_name == "Character Type": tag_char_type = tag_id # Get enum options enums = db.tag_enums(tag_id) hero_enum_id = None for enum in enums: if enum[dbtypes.TAG_ENUM_DATA_NAME] == "Hero": hero_enum_id = enum[dbtypes.TAG_ENUM_DATA_ID] # Set enum value if hero_enum_id: db.task_set_tag_enum(task_id, hero_enum_id, is_set=True) elif tag_name == "Render Engine" and tag_type == dbtypes.TAG_TYPE_STRING: tag_render_engine = tag_id db.task_set_tag_string(task_id, tag_id, "Arnold") elif tag_name == "Polygon Count" and tag_type == dbtypes.TAG_TYPE_INT: tag_poly_count = tag_id db.task_set_tag_int(task_id, tag_id, 45000) # Get task tag values task_tags = db.task_tags(task_id) for tag_val in task_tags: print(f"Tag: {tag_val[dbtypes.TASK_TAG_DATA_NAME]} = {tag_val[dbtypes.TASK_TAG_DATA_VALUE]}") ``` -------------------------------- ### Create and Manage Task Dependencies in Python Source: https://context7.com/cerebrohq/integration/llms.txt This Python code uses ctentaculo.pycerebro.database to establish and manage dependencies between tasks for scheduling purposes. It allows creating sequential links between tasks, retrieving existing task links, and dropping dependencies. The module requires database credentials and task IDs. ```python from ctentaculo.pycerebro import database, dbtypes db = database.Database() db.connect('username', 'password') # Get tasks modeling_task_id = 12345 rigging_task_id = 12346 animation_task_id = 12347 # Create sequential dependencies # Modeling -> Rigging link_id_1 = db.set_link_tasks( first_task_id=modeling_task_id, # Predecessor second_task_id=rigging_task_id # Follower ) # Rigging -> Animation link_id_2 = db.set_link_tasks( first_task_id=rigging_task_id, second_task_id=animation_task_id ) print(f"Created task dependencies: {link_id_1}, {link_id_2}") # Get task links links = db.task_links(rigging_task_id) for link in links: link_type = link[dbtypes.TASK_LINK_TYPE] linked_task_id = link[dbtypes.TASK_LINK_TASK_ID] print(f"Link type {link_type}: Task {linked_task_id}") # Remove dependency db.drop_link_tasks(link_id_1) ``` -------------------------------- ### Find Users and Assign to Tasks Source: https://context7.com/cerebrohq/integration/llms.txt This script iterates through a list of users, filters them based on name and resource flags, and then assigns the identified users to a specific task. It also demonstrates retrieving and printing current task allocations and removing a specific user from a task. Dependencies include the `dbtypes` module. ```python for user in users: user_name = user[dbtypes.USER_DATA_FULL_NAME] user_id = user[dbtypes.USER_DATA_ID] is_resource = dbtypes.USER_FLAG_IS_RESOURCE if "Smith" in user_name and not (user[dbtypes.USER_DATA_FLAGS] & is_resource): artist_ids.append(user_id) if artist_ids: db.task_set_allocated(task_id, artist_ids) print(f"Assigned {len(artist_ids)} users to task {task_id}") allocated = db.task_allocated(task_id) for allocation in allocated: print(f"User: {allocation[dbtypes.TASK_ALLOCATED_USER_NAME]} (ID: {allocation[dbtypes.TASK_ALLOCATED_USER_ID]})") if artist_ids: db.task_remove_allocated(task_id, artist_ids[0]) ``` -------------------------------- ### Execute Custom SQL Queries with Parameters (Python) Source: https://context7.com/cerebrohq/integration/llms.txt Allows execution of custom SQL queries against the database for advanced data retrieval and manipulation. Supports both direct queries and parameterized queries to prevent SQL injection. Requires a database connection and returns query results as a list of rows. ```python from ctentaculo.pycerebro import database db = database.Database() db.connect('username', 'password') # Execute custom query query = """ SELECT t.uid, t.name, t.progress, s.name as status_name FROM task t LEFT JOIN status s ON t.status = s.uid WHERE t.progress < 50 AND t.progress > 0 ORDER BY t.start_time DESC LIMIT 10 """ # Execute query (use %s for parameters) results = db.execute(query) for row in results: task_id, task_name, progress, status = row print(f"Task {task_id}: {task_name} - {progress}% ({status})") # Parameterized query query_with_params = """ SELECT uid, name FROM task WHERE activity = %s AND project_id = %s """ activity_id = 5 project_id = 100 results = db.execute(query_with_params, activity_id, project_id) print(f"Found {len(results)} tasks") ``` -------------------------------- ### Copy and Replicate Tasks with Hierarchy and Settings (Python) Source: https://context7.com/cerebrohq/integration/llms.txt Duplicates tasks, including their sub-tasks and associated settings like links, tags, assignments, and events. This function requires a database connection and takes a template task ID, target parent ID, and a list of tasks to copy with new names as input. It returns the IDs of the newly created tasks. ```python from ctentaculo.pycerebro import database, dbtypes db = database.Database() db.connect('username', 'password') # Get template task to copy template_task_id = 12345 target_parent_id = 10000 # Define copies with new names tasks_to_copy = [ (template_task_id, 'Character_A_Model'), (template_task_id, 'Character_B_Model'), (template_task_id, 'Character_C_Model'), ] # Copy with options new_task_ids = db.copy_tasks( task_id=target_parent_id, tasks_list=tasks_to_copy, flags=( dbtypes.COPY_TASKS_SUB_TASKS | # Copy subtasks dbtypes.COPY_TASKS_INTERNAL_LINKS | # Copy task links dbtypes.COPY_TASKS_TAGS | # Copy tag values dbtypes.COPY_TASKS_ASSIGNED_USERS | # Copy user assignments dbtypes.COPY_TASKS_EVENTS # Copy messages ) ) print(f"Created {len(new_task_ids)} new tasks: {new_task_ids}") # Get details of new tasks for new_id in new_task_ids: task = db.task(new_id) print(f"New task: {task[dbtypes.TASK_DATA_NAME]} (ID: {new_id})") ``` -------------------------------- ### Assign Users to Tasks (Python) Source: https://context7.com/cerebrohq/integration/llms.txt Assigns or removes users from a task within the Cerebro system. The code retrieves a list of all users, filters for artist IDs, and then proceeds to add or remove these users from a specified task. Requires the `ctentaculo.pycerebro` module. ```python from ctentaculo.pycerebro import database, dbtypes db = database.Database() db.connect('username', 'password') task_id = 12345 # Get all users users = db.users() artist_ids = [] ``` -------------------------------- ### Add Messages and Reports to Tasks Source: https://context7.com/cerebrohq/integration/llms.txt This Python script demonstrates how to add different types of messages to a task, including reviews with confirmed working time, work reports with updated status, and simple notes. It also shows how to retrieve and display all messages associated with a task. Requires `database` and `dbtypes` from `ctentaculo.pycerebro`. ```python from ctentaculo.pycerebro import database, dbtypes db = database.Database() db.connect('username', 'password') task_id = 12345 # Add review message (60 minutes confirmed time) review_id = db.add_review( task_id=task_id, message_id=None, # No reply to previous message html_text="

Model looks good, minor adjustments needed on proportions

", minutes=60 ) # Add work report (180 minutes = 3 hours) report_id = db.add_report( task_id=task_id, message_id=review_id, # Reply to review html_text="

Completed modeling adjustments. Updated topology and UVs.

", minutes=180 ) # Add note without time tracking note_id = db.add_note( task_id=task_id, message_id=report_id, html_text="

Remember to check with supervisor before final submission

" ) # Get all task messages messages = db.task_messages(task_id) for msg in messages: msg_type = msg[dbtypes.MESSAGE_DATA_TYPE] msg_text = msg[dbtypes.MESSAGE_DATA_TEXT] msg_time = msg[dbtypes.MESSAGE_DATA_WORK_TIME] print(f"Message type {msg_type}: {msg_text[:50]}... ({msg_time} min)") ``` -------------------------------- ### Connect to Cerebro Database (Python) Source: https://context7.com/cerebrohq/integration/llms.txt Establishes a connection to the Cerebro database using either an existing client session or direct authentication with credentials. It verifies the connection and retrieves the current user ID. Requires the `ctentaculo.pycerebro` module. ```python from ctentaculo.pycerebro import database # Initialize database connection db = database.Database() # Method 1: Connect via running Cerebro client (preserves client connection) status = db.connect_from_cerebro_client() if status != 0: # Method 2: Direct authentication with credentials db.connect('username', 'password') # Verify connection is active if db.is_connected(): current_user = db.current_user_id() print(f"Connected as user ID: {current_user}") else: raise Exception("Failed to establish database connection") ``` -------------------------------- ### Query User Task List (Python) Source: https://context7.com/cerebrohq/integration/llms.txt Retrieves a list of tasks assigned to a specific user, with the option to include or exclude completed tasks. It iterates through the task list, extracting task details such as ID, name, progress, and status. Requires the `ctentaculo.pycerebro` module. ```python from ctentaculo.pycerebro import database, dbtypes db = database.Database() db.connect('username', 'password') user_id = db.current_user_id() # Get all incomplete tasks for current user todo_tasks = db.to_do_task_list(user_id, with_done_task=False) # Get all tasks including completed all_tasks = db.to_do_task_list(user_id, with_done_task=True) # Process task data for task in todo_tasks: task_id = task[dbtypes.TASK_DATA_ID] task_name = task[dbtypes.TASK_DATA_NAME] task_progress = task[dbtypes.TASK_DATA_PROGRESS] task_status = task[dbtypes.TASK_DATA_STATUS] print(f"Task: {task_name} (ID: {task_id}, Progress: {task_progress}%)") ``` -------------------------------- ### Manage Hashtags for Tasks, Messages, and Attachments in Python Source: https://context7.com/cerebrohq/integration/llms.txt This Python code demonstrates how to add, retrieve, and remove hashtags for tasks, messages, and attachments using the ctentaculo.pycerebro.database module. It requires database connection credentials and task/message identifiers. Hashtags are managed as lists of strings. ```python from ctentaculo.pycerebro import database, dbtypes db = database.Database() db.connect('username', 'password') task_id = 12345 message_id = 67890 # Set hashtags on task db.task_set_hashtags(task_id, ['urgent', 'clientreview', 'iteration3']) # Get task hashtags hashtags = db.task_hashtags(task_id) print(f"Task hashtags: {hashtags}") # Remove specific hashtag db.task_remove_hashtags(task_id, ['iteration3']) # Set hashtags on message db.message_set_hashtags(message_id, ['feedback', 'approved']) # Set hashtags on attachment (by attachment ID) attachments = db.task_attachments(task_id) for att in attachments: att_id = att[dbtypes.ATTACHMENT_DATA_ID] att_tag = att[dbtypes.ATTACHMENT_DATA_TAG] # Only tag file attachments, not thumbnails if att_tag == dbtypes.ATTACHMENT_TAG_FILE: db.attachment_set_hashtags(att_id, ['final', 'approved']) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.