13. TACTIC Python Client API Reference

13.1. abort

abort(ignore_files=False)

Abort the transaction. This undos all commands that occurred

from the beginning of the transactions

keyparam:

ignore_files: (boolean) - determines if any files moved into the

repository are left as is. This is useful for very long processes

where it is desireable to keep the files in the repository

even on abort.

example:

A full transaction inserting 10 shots. If an error occurs, all 10

inserts will be aborted.

server.start('Start adding shots')
try:
    for i in range(0,10):
        server.insert("prod/shot", { 'code': 'XG%0.3d'%i } )
except:
    server.abort()
else:
    server.finish("10 shots added")

13.2. add_config_element

add_config_element(search_type, view, name, class_name=None, display_options={}, action_class_name=None, action_options={}, element_attrs={},login=None, unique=True, auto_unique_name=False, auto_unique_view=False)

This method adds an element into a config. It is used by various

UI components to add new widget element to a particular view.

param:

search_type - the search type that this config belongs to

view - the specific view of the search type

name - the name of the element

keyparam:

class_name - the fully qualified class of the display

action_class_name - the fully qualified class of the action

display_options - keyward options in a dictionary to construct the specific display

action_options - keyward options in a dictionary to construct the specific action

element_attrs - element attributes in a dictionary

login - login name if it is for a specific user

unique - add an unique element if True. update the element if False.

auto_unique_name - auto generate a unique element and display view name

auto_unique_view - auto generate a unique display view name

return:

boolean - True

example:

This will add a new element to the "character" view for a 3D asset

search_type = 'prod/asset'
view = 'characters'
class_name = 'tactic.ui.common.SimpleElementWdg'
server.add_config_element(search_type, view, class_name)

This will add a new element named "user" to the "definition" view. It contains detailed display and action nodes

data_dict = {} # some data here
search_type = 'prod/asset'
server.add_config_element(search_type, 'definition', 'user',  class_name = data_dict['class_name'], display_options=data_dict['display_options'], element_attrs=data_dict['element_attrs'], unique=True, action_class_name=data_dict['action_class_name'], action_options=data_dict['action_options'])

13.3. add_dependency

add_dependency(snapshot_code, file_path, type=ref)

Append a dependency referent to an existing check - in.

All files are uniquely containe by a particular snapshot. Presently,

this method does a reverse lookup by file name. This assumes that

the filename is unique within the system, so it is not recommended

unless it is known that naming conventions will produce unique

file names for every this particular file. If this is not the

case, it is recommended that add_dependency_by_code() is used.

param:

snapshot_code - the unique code identifier of a snapshot

file_path - the path of the dependent file. This function is able

reverse map the file_path to the appropriate snapshot

keyparam:

type - type of dependency. Values include ref and input_ref

ref = hierarchical reference: ie A contains B

input_ref = input reference: ie: A was used to create B

tag - a tagged keyword can be added to a dependency to categorize

the different dependencies that exist in a snapshot

return:

dictionary - the resulting snapshot

13.4. add_dependency_by_code

add_dependency_by_code(to_snapshot_code, from_snapshot_code, type=ref)

Append a dependency reference to an existing checkin. This dependency

is used to connect various checkins together creating a separate

dependency tree for each checkin.

param:

to_snapshot_code: the snapshot code which the dependency will be

connected to

from_snapshot_code: the snapshot code which the dependency will be

connected from

type - type of dependency. Values include ref and input_ref

ref = hierarchical reference: ie A contains B

input_ref - input reference: ie: A was used to create B

tag - a tagged keyword can be added to a dependency to categorize

the different dependencies that exist in a snapshot

return:

dictionary - the resulting snapshot

13.5. add_directory

add_directory(snapshot_code, dir, file_type=main, mode="copy", dir_naming=', file_naming=')

Add a full directory to an already existing checkin.

This informs TACTIC to treat the entire directory as single entity

without regard to the structure of the contents. TACTIC will not

know about the individual files and the directory hierarchy within

the base directory and it it left up to the and external program

to intepret and understand this.

This is often used when logic on the exact file structure exists in

some external source outside of TACTIC and it is deemed to complictaed

to map this into TACTIC’s snapshot definition.

param:

snapshot_code - a unique identifier key representing an sobject

dir - the directory that needs to be checked in

keyparam:

file_type - file type is used more as snapshot type here

mode - copy, move, preallocate, manual, inplace

dir_naming - explicitly set a dir_naming expression to use

file_naming - explicitly set a file_naming expression to use

return:

dictionary - snapshot

example:

This will create a new snapshot for a search_key and add a directory using manual mode

dir = 'C:/images'
handoff_dir = my.server.get_handoff_dir()
shutil.copytree('%s/subfolder' %dir, '%s/images/subfolder' %handoff_dir)

snapshot_dict = my.server.create_snapshot(search_key, context='render')
snapshot_code = snapshot_dict.get('code')
my.server.add_directory(snapshot_code, dir, file_type='dir', mode='manual')

13.6. add_file

add_file(snapshot_code, file_path, file_type=main, use_handoff_dir=False, mode=None, create_icon=False)

Add a file to an already existing snapshot. This method is used in

piecewise checkins. A blank snapshot can be created using

create_snapshot(). This method can then be used to successively

add files to the snapshot.

In order to check in the file, the server will need to have access

to these files. There are a number of ways of getting the files

to the server. When using copy or move mode, the files are either

copied or moved to the "handoff_dir". This directory

is an agreed upon directory in which to handoff the files to the

server. This mode is generally used for checking in user files.

For heavy bandwidth checkins, it is recommended to user preallocated

checkins.

param:

snapshot_code - the unique code identifier of a snapshot

file_path - path of the file to add to the snapshot.

Optional: this can also be an array to add multiple files at once.

This has much faster performance that adding one file at a time.

Also, note that in this case, file_types must be an array

of equal size.

keyparam:

file_type - type of the file to be added.

Optional: this can also be an array. See file_path argument

for more information.

use_handoff_dir - DEPRECATED: (use mode arg) use handoff dir to checkin

file. The handoff dir is an agreed upon directory between the

client and server to transfer files.

mode - upload|copy|move|manual|inplace

the file to the server.

create_icon - (True|False) determine whether to create an icon for

this appended file. Only 1 icon should be created for each

snapshot.

dir_naming - explicitly set a dir_naming expression to use

file_naming - explicitly set a file_naming expression to use

return:

dictionary - the resulting snapshot

example:

This will create a blank model snapshot for character chr001 and

add a file

search_type = 'prod/asset'
code = 'chr001'
search_key = server.build_search_type(search_type, code)
context = 'model'
path = "./my_model.ma"

snapshot = server.create_snapshot(search_key, context)
server.add_file( snapshot.get('code'), path )

Different files should be separated by file type. For example,

to check in both a maya and houdin file in the same snapshot:

maya_path = "./my_model.ma"
houdini_path = "./my_model.hip"

server.add_file( snapshot_code, maya_path, file_type='maya' )
server.add_file( snapshot_code, houdini_path, file_type='houdini' )

To transfer files by uploading (using http protocol):

server.add_file( snapshot_code, maya_path, mode='upload' )

To create an icon for this file

path = 'image.jpg'
server.add_file( snapshot_code, path, mode='upload', create_icon=True )

To add multiple files at once

file_paths = [maya_path, houdini_path]
file_types ['maya', 'houdini']
server.add_file( snapshot_code, file_paths, file_types=file_types, mode='upload')

13.7. add_group

add_group(snapshot_code, file_path, file_type, file_range, use_handoff_dir=False, mode=None)

Add a file range to an already existing snapshot

param:

snapshot_code - the unique code identifier of a snapshot

file_path - path of the file to add to the snapshot

file_type - type of the file to be added.

file_range - range with format s

keyparam:

use_handoff_dir - use handoff dir to checkin file

mode - one of copy,move,preallocate

return:

dictionary - the resulting snapshot

13.8. add_initial_tasks

add_initial_tasks(search_key, pipeline_code=None, processes=[])

Add initial tasks to an sobject

param:

search_key - the key identifying a type of sobject as registered in

the search_type table.

keyparam:

pipeline_code - override the sobject’s pipeline and use this one instead

processes - create tasks for the given list of processes

return:

list - tasks created

13.9. split_search_key

split_search_key(search_key)

Convenience method to split a search_key in into its search_type and search_code/id components. Note: only accepts the new form prod/asset?project=sample3d&code=chr001

param:

search_key - the unique identifier of a sobject

return:

tuple - search type, search code/id

13.10. build_search_key

build_search_key(search_type, code, project_code=None, column=code)

Convenience method to build a search key from its components. A

search_key uniquely indentifies a specific sobject. This string

that is returned is heavily used as an argument in the API to

identify an sobject to operate one

A search key has the form: "prod/shot?project=bar&code=XG001"

where search_type = "prod/shot", project_code = "bar" and code = "XG001"

param:

search_type - the unique identifier of a search type: ie prod/asset

code - the unique code of the sobject

keyparam:

project_code - an optional project code. If this is not

included, the project from get_ticket() is added.

return:

string - search key

example:

search_type = "prod/asset"
code = "chr001"
search_key = server.build_search_key(search_type, code)
e.g. search_key = prod/asset?project=code=chr001
search_type = "sthpw/login"
code = "admin"
search_key = server.build_search_key(search_type, code, column='code')
e.g. search_key = sthpw/login?code=admin

13.11. get_by_search_key

get_by_search_key(search_key)

Get the info on an sobject based on search key

param:

search_key - the key identifying a type of sobject as registered in

the search_type table.

return:

list of dictionary - sobjects that represent values of the sobject in the

form of name:value pairs

13.12. build_search_type

build_search_type(search_type, project_code=None)

Convenience method to build a search type from its components. It is

a simple method that build the proper format for project scoped search

types. A full search type has the form:

prod/asset?project=bar.

It uniquely defines a type of sobject in a project.

param:

search_type - the unique identifier of a search type: ie prod/asset

project_code (optional) - an optional project code. If this is not

included, the project from get_ticket() is added.

return:

search type string

example

search_type = "prod/asset"
full_search_type = server.build_search_type(search_type)

13.13. create_search_type

create_search_type(search_type, title, description="", has_pipeline=False)

Create a new search type

param:

search_type - Newly defined search_type

title - readable title to display this search type as

keyparam:

description - a brief description of this search type

has_pipeline - determines whether this search type goes through a

pipeline. Simply puts a pipeline_code column in the table.

return

string - the newly created search type

13.14. checkout

checkout(search_key, context, version=-1, file_type=main, dir=', level_key=None, to_sandbox_dir=False, mode='copy)

Check out files defined in a snapshot from the repository. This

will copy files to a particular directory so that a user can work

on them.

param:

search_key - a unique identifier key representing an sobject

context - context of the snapshot

keyparam:

version - version of the snapshot

file_type - file type defaults to main. If set to *, all paths are checked out

level_key - the unique identifier of the level in the form of a search key

to_dir - destination directory defaults to .

to_sandbox_dir - (True|False) destination directory defaults to

sandbox_dir (overrides "to_dir" arg)

mode - (copy|download)

to copy the files to the destination location

return:

list - a list of paths that were checked out

13.15. clear_upload_dir

clear_upload_dir()

Clear the upload directory to ensure clean checkins

param:

None

keyparam:

None

return:

None

13.16. connect_sobjects

connect_sobjects(src_sobject, dst_sobject, context=default)

Connect two sobjects together

param:

src_sobject - the original sobject from which the connection starts

dst_sobject - the sobject to which the connection connects to

keyparam:

context - an arbirarty parameter which defines type of connection

return:

dictionary - the last connection sobject created

13.17. set_current_snapshot

set_current_snapshot(snapshot_code)

Set this snapshot as a "current" snapshot

param:

snapshot_code - unique code of snapshot

return:

string - the resulting snapshot xml

13.18. get_expanded_paths_from_snapshot

get_expanded_paths_from_snapshot(snapshot_code, file_type=main)

Return the expanded path of a snapshot (used for

ranges of files)

param:

snapshot_code - the unique code of the snapshot

keyparam:

file_type - each file in a snapshot is identified by a file type.

This parameter specifies which type. Defaults to main

return:

string - path

13.19. get_all_paths_from_snapshot

get_all_paths_from_snapshot(snapshot_code, mode=client_repo, expand_paths=False, filename_mode='')

Get all paths from snapshot

param:

snapshot_code - the unique code of the snapshot

keyparam:

mode - forces the type of folder path returned to use the value from the

appropriate tactic_<SERVER_OS> - conf.xml configuration file.

Values include lib, web, local_repo, sandbox, client_repo, relative

lib = the NFS asset directory from the server point of view

web = the http asset directory from the client point of view

local_repo = the local sync of the TACTIC repository

sandbox = the local sandbox (work area) designated by TACTIC

client_repo (default) = the asset directory from the client point of view

If there is no value for win32_client_repo_dir or linux_client_repo_dir

in the config, then the value for asset_base_dir will be used instead.

relative = the relative direcory without any base

expand_paths - expand the paths of a sequence check

filename_mode - source or '', where source reveals the source_path of the check

file_types - list: only return files in snapshot with these types

return:

list - paths

13.20. get_path_from_snapshot

get_path_from_snapshot(snapshot_code, file_type=main, mode=client_repo)

Get a full path from a snapshot

param:

snapshot_code - the unique code / search_key of the snapshot

keyparam:

file_type - each file in a snapshot is identified by a file type.

This parameter specifies which type. Defaults to main

mode - Forces the type of folder path returned to use the value from the

appropriate tactic_<SERVER_OS> - conf.xml configuration file.

Values include lib, web, local_repo, sandbox, client_repo, relative

lib = the NFS asset directory from the server point of view

web = the http asset directory from the client point of view

local_repo = the local sync of the TACTIC repository

sandbox = the local sandbox (work area) designated by TACTIC

client_repo (default) = the asset directory from the client point of view

If there is no value for win32_client_repo_dir or linux_client_repo_dir

in the config, then the value for asset_base_dir will be used instead.

relative = the relative direcory without any base

return:

string - the directory to copy a file to handoff to Tactic without having to

go through http protocol

example:

If the tactic_<SERVER_OS> - conf.xml configuration file contains the following:

<win32_client_repo_dir>T:/assets</win32_client_repo_dir>

and if the call to the method is as follows:

snapshot = server.create_snapshot(search_key, context)
code = snapshot.get('code')
server.get_path_from_snapshot(snapshot.get('code'))

# in a trigger
snapshot_key = my.get_input_value("search_key")
server.get_path_from_snapshot(snapshot_key)

Then, on a Windows client, get_path_from_snapshot() will return:

T:/assets/sample3d/asset/chr/chr003/scenes/chr003_rig_v003.txt

13.21. get_snapshot

get_snapshot(search_key, context="publish", version=-1, level_key=None, include_paths=False, include_full_xml=False, include_paths_dict=False, include_files=False, include_web_paths_dict=False, versionless=False)

Method to retrieve an sobject’s snapshot

Retrieve the latest snapshot

param:

search_key - unique identifier of sobject whose snapshot we are

looking for

keyparam:

process - the process of the snapshot

context - the context of the snapshot

version - snapshot version

revision - snapshot revision

level_key - the unique identifier of the level in the form of a search key

include_paths - flag to include a list of paths to the files in this

snapshot.

include_full_xml - whether to include full xml in the return

include_paths_dict - flag to specify whether to include a

paths_dict property containing a dict of all paths in the

dependent snapshots

include_web_paths_dict - flag to specify whether to include a

web_paths_dict property containing a dict of all web paths in

the returned snapshots

include_files - includes all of the file objects referenced in the

snapshots

versionless - boolean to return the versionless snapshot, which takes a version of

return:

dictionary - the resulting snapshot

example:

    search_key = 'prod/asset?project=sample3d&code=chr001'
    snapshot = server.get_snapshot(search_key, context='icon', include_files=True)
    # get the versionless snapshot
    search_key = 'prod/asset?project=sample3d&code=chr001'
    snapshot = server.get_snapshot(search_key, context='anim', include_paths_dict=True, versionless=True)

13.22. create_snapshot

create_snapshot(search_key, context, snapshot_type="file", description="No description", is_current=True, level_key=None, is_revision=False, triggers=True )

Create an empty snapshot

param:

search_key - a unique identifier key representing an sobject

context - the context of the checkin

keyparam:

snapshot_type - [optional] descibes what kind of a snapshot this is.

More information about a snapshot type can be found in the

prod/snapshot_type sobject

description - [optional] optional description for this checkin

is_current - flag to determine if this checkin is to be set as current

is_revision - flag to set this as a revision instead of a version

level_key - the unique identifier of the level that this

is to be checked into

triggers - boolean to fire triggers on insert

return:

dictionary - representation of the snapshot created for this checkin

13.23. create_task

create_task(search_key, process="publish", subcontext=None, description=None, bid_start_date=None, bid_end_date=None, bid_duration=None, assigned=None)

Create a task for a particular sobject

param:

search_key - the key identifying a type of sobject as registered in

the search_type table.

keyparam:

process - process that this task belongs to

subcontext - the subcontext of the process (context = procsss/subcontext)

description - detailed description of the task

bid_start_date - the expected start date for this task

bid_end_date - the expected end date for this task

bid_duration - the expected duration for this task

assigned - the user assigned to this task

return:

dictionary - task that was created

13.24. directory_checkin

directory_checkin(search_key, context, dir, snapshot_type="directory", description="No description", file_type=main, is_current=True, level_key=None, metadata={}, mode="copy", is_revision=False, checkin_type="strict")

Check in a directory of files. This informs TACTIC to treat the

entire directory as single entity without regard to the structure

of the contents. TACTIC will not know about the individual files

and the directory hierarchy within the base directory and it it left

up to the and external program to intepret and understand this.

This is often used when logic on the exact file structure exists in

some external source outside of TACTIC and it is deemed too complicated

to map this into TACTIC’s snapshot definition.

param:

search_key - a unique identifier key representing an sobject

dir - the directory that needs to be checked in

keyparam:

snapshot_type - type of snapshot this checkin will have

description - description related to this checkin

file_type - the type of file that will be associated with this group

is_current - makes this snapshot current

level_key - the search key of the level if used

metadata - add metadata to snapshot

mode - determines whether the files passed in should be copied, moved

or uploaded. By default, this is copy

is_revision - flag to set this as a revision instead of a version

checkin_type - auto or strict which controls whether to auto create versionless

return:

dictionary - snapshot

13.25. delete_sobject

delete_sobject(search_key)

Invoke the delete method. Note: this function may fail due

to dependencies. Tactic will not cascade delete. This function

should be used with extreme caution because, if successful, it will

permanently remove the existence of an sobject

param:

search_key - a unique identifier key representing an sobject.

Note: this can also be an array.

return:

dictionary - a sobject that represents values of the sobject in the

form name:value pairs

13.26. download

download(my, url, to_dir=".", filename='', md5_checksum="")

Download a file from a given url

param:

url - the url source location of the file

keyparam:

to_dir - the directory to download to

filename - the filename to download to, defaults to original filename

md5_checksum - an md5 checksum to match the file against

return:

string - path of the file donwloaded

13.27. eval

eval(expression, search_keys=[], mode=None, single=False, vars={}, show_retired=False)

Evaluate the expression. This expression uses the TACTIC expression

language to retrieve results. For more information, refer to the

expression language documentation.

param:

expression - string expression

keyparam:

search_keys - the starting point for the expression.

mode - string|expression

single - True|False

vars - user defined variable

show_retired - defaults to False to not return retired items

return:

results of the expression. The results depend on the exact nature

of the expression.

example:

#1. Search for snapshots with context beginning with model for the asset with the search key prod/asset?project=sample3d&id=96

server = TacticServerStub.get()
exp = "@SOBJECT(sthpw/snapshot['context','EQ','^model'])"
result = server.eval(exp, search_keys=['prod/asset?project=sample3d&id=96'])

Please refer to the expression language documentation for numerous

examples on how to use the expression language.

13.28. execute_cmd

execute_cmd(class_name, args={}, values={})

Execute a command

param:

class_name - the fully qualified class name of the widget

keyparam:

args - keyword arguments required to create a specific widget

values - form values that are passed in from the interface

return:

string - description of command

13.29. finish

finish()

End the current transaction and cleans it up

params:

description: this will be recorded in the transaction log as the

description of the transction

example:

A full transaction inserting 10 shots. If an error occurs, all 10

inserts will be aborted.

server.start('Start adding shots')
try:
    for i in range(0,10):
        server.insert("prod/shot", { 'code': 'XG%0.3d'%i } )
except:
    server.abort()
else:
    server.finish("10 shots added")

13.30. generate_ticket

generate_ticket()

Ask the server to generate a ticket explicity used for your own commands

return - a string representing the transaction ticket

13.31. get_all_children

get_all_children(search_key, child_type, filters=[], columns=[])

Get all children of a particular child type of an sobject

param:

search_key - a unique identifier key representing an sobject

child_type - the search_type of the children to search for

keyparam:

filters - extra filters on the query : see query method for examples

columns - list of column names to be included in the returned dictionary

return:

list of dictionary - a list of sobjects dictionaries

13.32. get_dependencies

get_dependencies(snapshot_code, mode=explicit, tag=main, include_paths=False, include_paths_dict=False, include_files=False, repo_mode=client_repo, show_retired=False)

Return the dependent snapshots of a certain tag

params:

snapshot_code - unique code of a snapshot

keyparams:

mode - explict (get version as defined in snapshot)

  • - latest
  • - current

tag - retrieve only dependencies that have this named tag

include_paths - flag to specify whether to include a paths property

containing all of the paths in the dependent snapshots

include_paths_dict - flag to specify whether to include a

paths_dict property containing a dict of all paths in the

dependent snapshots

include_files - includes all of the file objects referenced in the

snapshots

repo_mode - client_repo, web, lib, relative

show_retired - defaults to False so that it doesn’t show retired dependencies

return:

a list of snapshots

13.33. query_snapshots

query_snapshots(filters=None, columns=None, order_bys=[], show_retired=False, limit=None, offset=None, single=False, include_paths=False, include_full_xml=False, include_paths_dict=False, include_parent=False, include_files=False)

thin wrapper around query, but is specific to querying snapshots

with some useful included flags that are specific to snapshots

params:

ticket - authentication ticket

filters - (optional) an array of filters to alter the search

columns - (optional) an array of columns whose values should be

retrieved

order_bys - (optional) an array of order_by to alter the search

show_retired - (optional)

returned

limit - sets the maximum number of results returned

single - returns a single sobject that is not wrapped up in an array

include_paths - flag to specify whether to include a paths property

containing a list of all paths in the dependent snapshots

include_paths_dict - flag to specify whether to include a

paths_dict property containing a dict of all paths in the

dependent snapshots

include_full_xml - flag to return the full xml definition of a snapshot

include_parent - includes all of the parent attributes in a parent dictionary

include_files - includes all of the file objects referenced in the

snapshots

return:

list of snapshots

13.34. get_by_code

get_by_code(search_type, search_code)

Get the info on an sobject based on search code

param:

search_type - the search_type of the sobject to search for

code - the code of the sobject to search for

return:

sobject - a dictionary that represents values of the sobject in the

form name/value pairs

13.35. get_child_types

get_child_types(search_key)

Get all the child search types

param:

search_key - a unique identifier key representing an sobject

return:

list - the child search types

13.36. get_all_dependencies

get_all_dependencies(snapshot_code, mode=explicit, type=ref, include_paths=False, include_paths_dict=False, include_files=False, repo_mode=client_repo, show_retired=False)

Retrieve the latest dependent snapshots of the given snapshot

param:

snapshot_code - the unique code of the snapshot

keyparam:

mode - explicit (get version as defined in snapshot)

  • - latest
  • - current

type - one of ref or input_ref

include_paths - flag to specify whether to include a paths property

containing all of the paths in the dependent snapshots

include_paths_dict - flag to specify whether to include a

paths_dict property containing a dict of all paths in the

dependent snapshots

include_files - includes all of the file objects referenced in the

snapshots

repo_mode - client_repo, web, lib, relative

show_retired - defaults to False so that it doesn’t show retired dependencies

return:

list - snapshots

13.37. get_client_api_version

get_client_api_version()

return:

string - client api version

13.38. get_home_dir

get_home_dir()

OS independent method to Get the home directory of the current user.

return:

string - home directory

13.39. get_client_dir

get_client_dir(snapshot_code, file_type=main, mode=client_repo)

Get a dir segment from a snapshot

param:

snapshot_code - the unique code of the snapshot

keyparam:

file_type - each file in a snapshot is identified by a file type.

This parameter specifies which type. Defaults to main

mode - Forces the type of folder path returned to use the value from the

appropriate tactic_<SERVER_OS> - conf.xml configuration file.

Values include lib, web, local_repo, sandbox, client_repo, relative

lib = the NFS asset directory from the server point of view

web = the http asset directory from the client point of view

local_repo = the local sync of the TACTIC repository

sandbox = the local sandbox (work area) designated by TACTIC

client_repo (default) = the asset directory from the client point of view

If there is no value for win32_client_repo_dir or linux_client_repo_dir

in the config, then the value for asset_base_dir will be used instead.

relative = the relative direcory without any base

return:

string - directory segment for a snapshot and file type

example:

If the tactic_<SERVER_OS> - conf.xml configuration file contains the following:

<win32_client_repo_dir>T:/assets</win32_client_repo_dir>

and if the call to the method is as follows:

snapshot = server.create_snapshot(search_key, context)
code = snapshot.get('code')
server.get_path_from_snapshot(snapshot.get('code'))

Then, on a Windows client, get_client_dir() will return:

T:/assets/sample3d/asset/chr/chr003/scenes

13.40. get_config_definition

get_config_definition(search_type, view, element_name, personal=False)

Get the widget configuration definition for an element

param:

search_type - search type that this config relates to

view - view to look for the element

element_name - name of the element

keyparam:

personal - True if it is a personal definition

return:

string - xml of the configuration

13.41. get_client_version

get_client_version()

return:

string - Version of TACTIC that this client came from

13.42. get_connected_sobject

get_connected_sobject(src_sobject, context=default)

Get the connected sobject

params

src_sobject - the original sobject from which the connection starts

keyparam:

context - an arbirarty parameter which defines type of connection

return:

dict - a single connected sobject

13.43. get_column_info

get_column_info(search_type)

Get column information of the table given a search type

param:

search_type - the key identifying a type of sobject as registered in

the search_type table.

return - a dictionary of info for each column

13.44. get_handoff_dir

get_handoff_dir()

Return a temporary path that files can be copied to

return:

string - the directory to copy a file to handoff to TACTIC

without having to go through http protocol

13.45. get_md5_info

get_md5_info(md5_list, texture_codes, new_paths, parent_code, texture_cls, file_group_dict, project_code)

Get md5 info for a given list of texture paths, mainly returning if this md5 is a match or not

param:

md5_list - md5_list

new_paths - list of file_paths

parent_code - parent code

texture_cls - Texture or ShotTexture

file_group_dict - file group dictionary storing all the file groups

project_code - project_code

mode - texture matching mode (md5, file_name)

return:

dictionary - a dictionary of path and a subdictionary of is_match, repo_file_code, repo_path, repo_file_range

13.46. get_pipeline_processes_info

get_pipeline_processes_info(search_key, recurse=False, related_process=None)

Retrieve the pipeline processes information of a specific sobject. It provides information from the perspective of a particular process if related_process is specified.

param:

search_key - a unique identifier key representing an sobject

keyparams:

recurse - boolean to control whether to display sub pipeline processes

related_process - given a process, it shows the input and output processes and contexts

return:

dictionary - process names of the pipeline or a dictionary if related_process is specified

13.47. get_preallocated_path

get_preallocated_path(snapshot_code, file_type=main, file_name=', mkdir=True, protocol='client_repo, ext='')

Get the preallocated path for this snapshot. It assumes that

this checkin actually exists in the repository and will create virtual

entities to simulate a checkin. This method can be used to determine

where a checkin will go. However, the snapshot must exist

using create_snapshot() or some other method. For a pure virtual naming

simulator, use get_virtual_snapshot_path().

param:

snapshot_code - the code of a preallocated snapshot. This can be

create by get_snapshot()

keyparam:

file_type - the type of file that will be checked in. Some naming

conventions make use of this information to separate directories

for different file types

file_name - the desired file name of the preallocation. This information

may be ignored by the naming convention or it may use this as a

base for the final file name

mkdir - an option which determines whether the directory of the

preallocation should be created

protocol - It’s either client_repo, sandbox, or None. It determines whether the

path is from a client or server perspective

ext - force the extension of the file name returned

return:

string - the path where add_file() expects the file to be checked into

example:

it saves time if you get the path and copy it to the final destination first.

snapshot = my.server.create_snapshot(search_key, context)
snapshot_code = snapshot.get('code')
file_name = 'input_file_name.txt'
orig_path = 'C:/input_file_name.txt'
path = my.server.get_preallocated_path(snapshot_code, file_type, file_name)

# the path where it is supposed to go is generated
new_dir = os.path.dirname(path)
if not os.path.exists(new_dir):
    os.makedirs(new_dir)
shutil.copy(orig_path, path)
my.server.add_file(snapshot_code, path, file_type, mode='preallocate')

13.48. get_protocol

get_protocol()

return:

string - local or xmlrpc

13.49. reactivate_sobject

reactivate_sobject(search_key)

Invoke the reactivate method.

param:

search_key - the unige key identifying the sobject.

return:

dictionary - sobject that represents values of the sobject in the

form name:value pairs

13.50. get_resource_path

get_resource_path(login=None)

Get the resource path of the current user. It differs from

create_resource_paths() which actually create dir. The resource path

identifies the location of the file which is used to cache connection information.

An exmple of the contents is shown below:

login=admin
server=localhost
ticket=30818057bf561429f97af59243e6ef21
project=unittest

The contents in the resource file represent the defaults to use

when connection to the TACTIC server, but may be overriden by the

API methods: set_ticket(), set_server(), set_project() or the

environment variables: TACTIC_TICKET, TACTIC_SERVER, and TACTIC_PROJECT

Typically this method is not explicitly called by API developers and

is used automatically by the API server stub. It attempts to get from

home dir first and then from temp_dir is it fails.

param:

login (optional) - login code. If not provided, it gets the current system user

return:

string - resource file path

13.51. get_server_api_version

get_server_api_version()

return:

string - server API version

13.52. get_ticket

get_ticket(login, password)

Get an authentication ticket based on a login and password.

This function first authenticates the user and the issues a ticket.

The returned ticket is used on subsequent calls to the client api

param:

login - the user that is used for authentications

password - the password of that user

return:

string - ticket key

13.53. get_unique_sobject

get_unique_sobject(search_type, data={})

This is a special convenience function which will query for an

sobject and if it doesn’t exist, create it. It assumes that this

object should exist and spares the developer the logic of having to

query for the sobject, test if it doesn’t exist and then create it.

param:

search_type - the type of the sobject

data - a dictionary of name/value pairs that uniquely identify this

sobject

return:

sobject - unique sobject matching the critieria in data

13.54. get_widget_setting

set_widget_settings(key, value)

Get widget setting for current user and project

param

key - unique key to identify this setting

return

value of setting

13.55. insert_update

insert_update(search_key, data, metadata={}, parent_key=None, info={}, use_id=False, triggers=True)

Insert if the entry does not exist, update otherwise

param:

search_key - a unique identifier key representing an sobject.

data - a dictionary of name/value pairs which will be used to update

the sobject defined by the search_key

keyparam:

metadata - a dictionary of values that will be stored in the metadata attribute if available

parent_key - set the parent key for this sobject

info - a dictionary of info to pass to the ApiClientCmd

use_id - use id in the returned search key

triggers - boolean to fire trigger on insert

return:

dictionary - represent the sobject with its current data.

13.56. insert_multiple

insert_multiple(data, metadata=[], parent_key=None, use_id=False, triggers=True)

Insert for several sobjects in one function call. The

data structure contains all the infon needed to update and is

formated as follows:

data = [

{ column1: value1, column2: value2, column3: value3 },

{ column1: value1, column2: value2, column3: value3 }

}

metadata = [

{ color: blue, height: 180 },

{ color: orange, height: 170 }

]

params:

search_type - the search_type attribute of the sType

data - a dictionary of name/value pairs which will be used to update

the sobject defined by the search_key

Note: this can also be an array. Each data dictionary element in

the array will be applied to the corresponding search key

keyparam:

parent_key - set the parent key for this sobject

use_id - boolean to control if id is used in the search_key in returning sobject dict

triggers - boolean to fire trigger on insert

return:

a list of all the inserted sobjects

13.57. log

log(level, message, category="default")

Log a message in the logging queue. It is often difficult to see output

of a trigger unless you are running the server in debug mode.

In production mode, the server sends the output to log files.

The log files are general buffered.

It cannot be predicted exactly when buffered output will be dumped to a file.

This log() method will make a request to the server.

The message will be immediately stored in the database in the debug log table.

param:

level - critical|error|warning|info|debug

message - freeform string describing the entry

keyparam:

category - a label for the type of message being logged.

It defaults to "default"

13.58. query

query(search_type, filters=[], columns=[], order_bys=[], show_retired=False, limit=None, offset=None, single=False, distinct=None, return_sobjects=False)

General query for sobject information

param:

search_type - the key identifying a type of sobject as registered in

the search_type table.

keyparam:

filters - an array of filters to alter the search

columns - an array of columns whose values should be

retrieved

order_bys - an array of order_by to alter the search

show_retired - sets whether retired sobjects are also

returned

limit - sets the maximum number of results returned

single - returns only a single object

distinct - specify a distinct column

return_sobjects - return sobjects instead of dictionary. This

works only when using the API on the server.

return:

list of dictionary/sobjects - Each array item represents an sobject

and is a dictionary of name/value pairs

example:

    filters = []
    filters.append( ("code", "XG002") )
    order_bys = ['timestamp desc']
    columns = ['code']
    server.query(ticket, "prod/shot", filters, columns, order_bys)

The arguments "filters", "columns", and "order_bys" are optional

The "filters" argument is a list. Each list item represents an

individual filter. The forms are as follows:

(column, value)             -> where column = value
(column, (value1,value2))   -> where column in (value1, value2)
(column, op, value)         -> where column op value
    where op is ('like', '<=', '>=', '>', '<', 'is', '~', '!~','~*','!~*)
(value)                     -> where value

13.59. redo

redo(transaction_ticket=None, transaction_id=None)

Redo an operation. If no transaction id is given, then the last

undone operation of this user on this project is redone

keyparam:

transaction_ticket - explicitly redo a specific transaction

transaction_id - explicitly redo a specific transaction by id

13.60. start

start(title, description='')

Start a transaction. All commands using the client API are bound

in a transaction. The combination of start(), finish() and abort()

makes it possible to group a series of API commands in a single

transaction. The start/finish commands are not necessary for

query operations (like query(…), get_snapshot(…), etc).

keyparam:

title - the title of the command to be executed. This will show up on

transaction log

description - the description of the command. This is more detailed.

transaction_ticket - optionally, one can provide the transaction ticket sequence

example:

A full transaction inserting 10 shots. If an error occurs, all 10

inserts will be aborted.

server.start('Start adding shots')
try:
    for i in range(0,10):
        server.insert("prod/shot", { 'code': 'XG%0.3d'%i } )
except:
    server.abort()
else:
    server.finish("10 shots added")

13.61. update

update(search_key, data={}, metadata={}, parent_key=None, info={}, use_id=False, triggers=True)

General update for updating sobject

param:

search_key - a unique identifier key representing an sobject.

Note: this can also be an array, in which case, the data will

be updated to each sobject represented by this search key

keyparam:

data - a dictionary of name/value pairs which will be used to update

the sobject defined by the search_key

Note: this can also be an array. Each data dictionary element in

the array will be applied to the corresponding search key

parent_key - set the parent key for this sobject

info - a dictionary of info to pass to the ApiClientCmd

metadata - a dictionary of values that will be stored in the metadata attribute if available

use_id - use id in the returned search key

triggers - boolean to fire trigger on update

return:

dictionary - represent the sobject with its current data.

If search_key is an array, This will be an array of dictionaries

13.62. SimpleUploadWdg

image

Description

The Simple Upload Widget is used for uploading files in-line in tables and also in edit windows. It is the simplest form of Tactic checkin as is allows for uploading of a single file and uses only a single hard coded (configured) checkin context.

Info

Name

Simple Upload Widget

Class

tactic.ui.widget.SimpleUploadWdg

Category

Edit Widgets

Supported Interfaces

TableWdg, EditWdg

TACTIC Version Support

2.5.0 \+

Required database columns

none

Implementation

This widget is available as part of the "preview" common column. It is also used when right-clicking on an item and choosing "Change preview" or "Checkin File"

Options

Common Name(s)/Title

Preview, Snapshot, Files

Context

TableWdg, EditWdg

Show Preview?

2.5.0 \+

Advanced

<element name='preview'>
  <display class='tactic.ui.widget.SimpleUploadWdg'>
    <context>icon</context>
  </display>
</element>

13.63. get_parent_type

get_parent_type(search_key)

Get of the parent search type

param:

search_key - a unique identifier key representing an sobject

return:

list - a list of child search_types

13.64. get_connected_sobjects

get_connected_sobjects(src_sobject, context=default)

Get all of the connected sobjects

param:

src_sobject - the original sobject from which the connection starts

keyparam:

context - an arbitrary parameter which defines type of connection

return:

list - a list of connected sobjects

13.65. simple_checkin

simple_checkin( search_key, context, file_path, snapshot_type="file", description="No description", use_handoff_dir=False, file_type="main", is_current=True, level_key=None, breadcrumb=False, metadata={}, mode=None, is_revision=False, info={}, keep_file_name=False, create_icon=True, checkin_cls=pyasm.checkin.FileCheckin, context_index_padding=None, checkin_type="strict", source_path=None, version=None )

Simple method that checks in a file.

param:

search_key - a unique identifier key representing an sobject

context - the context of the checkin

file_path - path of the file that was previously uploaded

keyparam:

snapshot_type - [optional] descibes what kind of a snapshot this is.

More information about a snapshot type can be found in the

prod/snapshot_type sobject

description - [optional] optional description for this checkin

file_type - [optional] optional description for this file_type

is_current - flag to determine if this checkin is to be set as current

level_key - the unique identifier of the level that this

is to be checked into

breadcrumb - flag to leave a .snapshot breadcrumb file containing

information about what happened to a checked in file

metadata - a dictionary of values that will be stored as metadata

on the snapshot

mode - inplace, upload, copy, move

is_revision - flag to set this as a revision instead of a version

create_icon - flag to create an icon on checkin

info - dict of info to pass to the ApiClientCmd

keep_file_name - keep the original file name

checkin_cls - checkin class

context_index_padding - determines the padding used for context

indexing: ie: design/0001

checkin_type - auto or strict which controls whether to auto create versionless

source_path - explicitly give the source path

version - force a version for this check

return:

dictionary - representation of the snapshot created for this checkin

13.66. group_checkin

group_checkin(search_key, context, file_path, file_range, snapshot_type="sequence", description="", file_type=main, metadata={}, mode=None, is_revision=False, info={} )

Check in a range of files. A range of file is defined as any group

of files that have some sequence of numbers grouping them together.

An example of this includes a range frames that are rendered.

Although it is possible to add each frame in a range using add_file,

adding them as as sequence is lightweight, often significantly reducing

the number of database entries required. Also, it is understood that

test files form a range of related files, so that other optimizations

and manipulations can be operated on these files accordingly.

param:

search_key - a unique identifier key representing an sobject

file_path - expression for file range: ./blah.##.jpg

file_type - the typ of file this is checked in as. Default = main

file_range - string describing range of frames in the form '1

keyparam:

snapshot_type - type of snapshot this checkin will have

description - description related to this checkin

file_type - the type of file that will be associated with this group

metadata - add metadata to snapshot

mode - determines whether the files passed in should be copied, moved

or uploaded. By default, this is a manual process (for backwards

compatibility)

is_revision - flag to set this as a revision instead of a version

info - dict of info to pass to the ApiClientCmd

return:

dictionary - snapshot

13.67. get_column_names

get_column_names(search_type)

This method will get all of the column names associated with a search

type

param:

search_type - the search type used to query the columns for

return

list of columns names

13.68. set_protocol

get_protocol()

params

string - local or xmlrpc

13.69. set_login_ticket

set_login_ticket(ticket)

Set the login ticket with the ticket key

13.70. get_parent

get_parent(search_key, columns=[], show_retired=True)

Get the parent of an sobject.

param:

search_key - a unique identifier key representing an sobject

keyparam:

columns - the columns that will be returned in the sobject

show_retired - it defaults to False so it does not show retired parent if that’s the case

return:

dictionary - the parent sobject

13.71. get_types_from_instance

get_types_from_instance(instance_type)

Get the connector types from an instance type

param:

instance_type - the search type of the instance

return:

tuple - (from_type, parent_type)

a tuple with the from_type and the parent_type. The from_type is

the connector type and the parent type is the search type of the

parent of the instance

13.72. undo

undo(transaction_ticket=None, transaction_id=None, ignore_files=False)

undo an operation. If no transaction id is given, then the last

operation of this user on this project is undone

keyparam:

transaction_ticket - explicitly undo a specific transaction

transaction_id - explicitly undo a specific transaction by id

ignore_files - flag which determines whether the files should

also be undone. Useful for large preallcoated checkins.

13.73. get_widget

get_widget(class_name, args={}, values={})

Get a defined widget

params:

class_name - the fully qualified class name of the widget

keyparams:

args - keyword arguments required to create a specific widget

values - form values that are passed in from the interface

return:

string - html form of the widget

example:

class_name = TableLayoutWdg

args = {

view: manage,

search_type: prod/asset,

}

widget = server.get_widget(class_name, args))

13.74. set_project

set_project(project_code)

Set the project code

13.75. execute_python_script

execute_python_script(script_path, kwargs)

Execute a python script defined in Script Editor

param:

script_path - script path in Script Editor, e.g. test/eval_sobj

keyparam:

kwargs - keyword arguments for this script

return:

dictionary - returned data structure

13.76. insert

insert(search_type, data, metadata={}, parent_key=None, info={}, use_id=False, triggers=True)

General insert for creating a new sobject

param:

search_type - the search_type attribute of the sType

data - a dictionary of name/value pairs which will be used to update

the sobject defined by the search_key.

parent_key - set the parent key for this sobject

keyparam:

metadata - a dictionary of values that will be stored in the metadata attribute

if available

info - a dictionary of info to pass to the ApiClientCmd

use_id - use id in the returned search key

triggers - boolean to fire trigger on insert

return:

dictionary - represent the sobject with it’s current data

example:

insert a new asset

search_type = "prod/asset"

{
    'code': chr001,
    'description': 'Main Character'
}

insert( search_type, data )

insert a new note with a shot parent

# get shot key
shot_key = server.build_search_key(search_type='prod/shot',code='XG001')

data = {
    'context': 'model',
    'note': 'This is a modelling note',
    'login': server.get_login()
}

server.insert( search_type, data, parent_key=shot_key)

insert a note without firing triggers

search_type = "sthpw/note"

data = {
    'process': 'roto',
    'context': 'roto',
    'note': 'The keys look good.',
    'project_code': 'art'
}

server.insert( search_type, data, triggers=False )

13.77. get_pipeline_processes

get_pipeline_processes(search_key, recurse=False)

DEPRECATED: use get_pipeline_processes_info()

Retrieve the pipeline processes information of a specific sobject.

param:

search_key - a unique identifier key representing an sobject

keyparams:

recurse - boolean to control whether to display sub pipeline processes

return:

list - process names of the pipeline

13.78. update_multiple

update_multiple(data, triggers=True)

Update for several sobjects with different data in one function call. The

data structure contains all the information needed to update and is

formated as follows:

data = {

search_key1: { column1: value1, column2: value2 }

search_key2: { column1: value1, column2: value2 }

}

params:

data - data structure containing update information for all

sobjects

keyparam:

data - a dictionary of name/value pairs which will be used to update

the sobject defined by the search_key

Note: this can also be an array. Each data dictionary element in

the array will be applied to the corresponding search key

triggers - boolean to fire trigger on insert

return:

None

13.79. get_related_types

get_related_types(search_type)

Get related search types given a search type

param:

search_type - the key identifying a type of sobject as registered in

the search_type table.

return - list of search_types

13.80. set_server

set_server(server_name)

Set the server name for this XML - RPC server

13.81. get_info_from_user

get_info_from_user(force=False)

Get input from the user about the users environment. Questions

asked pertain to the location of the tactic server, the project worked

on and the user’s login and password. This information is stored in

an .<login>.tacticrc file.

keyparam:

force - if set to True, it will always ask for new infomation from the

command prompt again

13.82. set_config_definition

set_config_definition(search_type, element_name, config_xml="", login=None)

Set the widget configuration definition for an element

param:

search_type - search type that this config relates to

element_name - name of the element

keyparam:

config_xml - The configuration xml to be set

login - A user’s login name, if specifically choosing one

return:

True on success, exception message on failure

13.83. get_server_version

get_server_version()

return:

string - server version

13.84. upload_file

upload_file(path)

Use http protocol to upload a file through http

param:

path - the name of the file that will be uploaded

13.85. update_config

update_config(search_type, view, element_names)

Update the widget configuration like ordering for a view

param:

search_type - search type that this config relates to

view - view to look for the element

element_names - element names in a list

return:

string - updated config xml snippet

13.86. execute_pipeline

execute_pipeline(pipeline_xml, package)

Spawn an execution of a pipeline as delivered from

get_pipeline_xml(). The pipeline is a xml document that describes

a set of processes and their handlers

param:

pipeline_xml - an xml document describing a standard Tactic pipeline.

package - a dictionary of data delivered to the handlers

return:

instance - a reference to the interpreter

13.87. set_widget_setting

set_widget_settings(key, value)

Set widget setting for current user and project

param

key - unique key to identify this setting

value - value the setting should be set to

return

None

13.88. retire_sobject

retire_sobject(search_key)

Invoke the retire method. This is preferred over delete_sobject if

you are not sure whether other sobjects has dependency on this.

param:

search_key - the unige key identifying the sobject.

return:

dictionary - sobject that represents values of the sobject in the

form name:value pairs

13.89. get_table_info

get_table_info(search_type)

Get column information of the table given a search type

param:

search_type - the key identifying a type of sobject as registered in

the search_type table.

return - a dictionary of info for each column

13.90. get_base_dirs

get_base_dirs()

Get all of the base directories defined on the server

return:

dictionary of all the important configured base directories

with their keys

13.91. get_paths

get_paths( search_key, context="publish", version=-1, file_type=main, level_key=None, single=False, versionless=False)

Get paths from an sobject

params:

search_key - a unique identifier key representing an sobject

keyparams:

context - context of the snapshot

version - version of the snapshot

file_type - file type defined for the file node in the snapshot

level_key - the unique identifier of the level that this

was checked into

single - If set to True, the first of each path set is returned

versionless - boolean to return the versionless snapshot, which takes a version of

return

A dictionary of lists representing various paths. The paths returned

are as follows:

  • - client_lib_paths: all the paths to the repository relative to the client
  • - lib_paths: all the paths to the repository relative to the server
  • - sandbox_paths: all of the paths mapped to the sandbox
  • - web: all of the paths relative to the http server

13.92. get_virtual_snapshot_path

get_virtual_snapshot_path(search_key, context, snapshot_type="file", level_key=None, file_type=main, file_name=', mkdirs=False, protocol='client_repo, ext='')

Create a virtual snapshot and returns a path that this snapshot

would generate through the naming conventions. This is most useful

testing naming conventions.

param:

snapshot creation:

  • -

search_key - a unique identifier key representing an sobject

context - the context of the checkin

keyparam:

snapshot_type - [optional] descibes what kind of a snapshot this is.

More information about a snapshot type can be found in the

prod/snapshot_type sobject

description - [optional] optional description for this checkin

level_key - the unique identifier of the level that this

is to be checked into

keyparam:

path creation:

  • -

file_type - the type of file that will be checked in. Some naming

conventions make use of this information to separate directories

for different file types

file_name - the desired file name of the preallocation. This information

may be ignored by the naming convention or it may use this as a

base for the final file name

mkdir - an option which determines whether the directory of the

preallocation should be created

protocol - It’s either client_repo, sandbox, or None. It determines whether the

path is from a client or server perspective

ext - force the extension of the file name returned

return:

string - path as determined by the naming conventions

13.93. get_plugin_dir

get_plugin_dir(plugin)

Return the web path for the specfied plugin

params:

plugin - plugin name

return:

string - the web path for the specified plugin