编程参考

CGTeamWork python client for humans.

cgtwq.login(account, password)[源代码]

Login on server.

参数
  • account (str) – Account name.

  • password (str) – Password.

引发

ValueError – When login fail.

返回

Account information.

返回类型

AccountInfo

cgtwq.get_account(token=None)[源代码]

Get account from token.

参数

token (str) – Server token

返回

Account name.

返回类型

str

cgtwq.get_account_id(token=None)[源代码]

Get account id from token.

参数

token (str) – Server token

返回

Account id.

返回类型

str

class cgtwq.DesktopClient(socket_url=None)[源代码]

Communicate with a CGTeamWork official GUI clients.

call(controller, method, **kwargs)[源代码]

Call method on the cgteamwork client.

参数
  • controller (str) – Client defined controller name.

  • method (str) – Client defined method name on the controller.

  • **kwargs – Client defined method keyword arguments.

返回

Received data.

返回类型

dict or str

connect()[源代码]

Update module config from desktop client.

current_select()

Get current selection from client.

返回

Current selection.

返回类型

Selection

static executable()[源代码]

Get a cgteamwork client executable.

返回

Executable path.

返回类型

text_type

is_logged_in()[源代码]

Check if client is logged in.

返回

True if client is logged in.

返回类型

bool

is_running()[源代码]

Check if client is running.

返回

True if client is running.

返回类型

bool

refresh(database, module)[源代码]

Refresh specified view in client if matched view is opened.

参数
  • database (text_type) – Database of view.

  • module (text_type) – Module of view.

refresh_selected(database, module)[源代码]

Refresh selected part of specified view in client if matched view is opened.

参数
  • database (text_type) – Database of view.

  • module (text_type) – Module of view.

selection()[源代码]

Get current selection from client.

返回

Current selection.

返回类型

Selection

server_http()[源代码]

Server http current using by client.

server_ip(max_age=5)[源代码]

Cached server ip.

start()[源代码]

Start client if not running.

token(max_age=2)[源代码]

Cached client token.

class cgtwq.Database(name)[源代码]

Database on server.

call(*args, **kwargs)[源代码]

Call on this database.

create_field(sign, type_, name=None, label=None)

Create new field in the module.

参数
  • sign (str) – Field sign

  • type_ (str) – Field type, see core.FIELD_TYPES.

  • name (str, optional) – Defaults to None. Field english name.

  • label (str, optional) – Defaults to None. Field chinese name.

delete_field(field_id)

Delete field in the module.

参数

id_ (str) – Field id.

filter(*filters)[源代码]

Filter modules in this database.

参数

*filters (FilterList, Filter) – Filters for server.

返回

Modules

返回类型

tuple[Module]

get_data(key, is_user=True)

Get additional data set in this database.

参数
  • key (text_type) – Data key.

  • is_user (bool, optional) – Defaults to True.

  • is_user is True, this data will be user specific. (If) –

返回

Data value.

返回类型

text_type

get_field(filters)
Get one field in the database.

filters (Filter or FilterList): Filter.

返回

Field information.

返回类型

FieldMeta

get_fields(filters=None)
Get fields in the database.

filters (Filter or FilterList, optional): Defaults to None. Filter.

返回

Field information.

返回类型

tuple[FieldMeta]

get_fileboxes(filters=None, id_=None)

Get fileboxes in this database.

参数
  • filters (FilterList, optional) – Defaults to None. Filters to get filebox.

  • id_ (text_type, optional) – Defaults to None. Filebox id.

引发
  • ValueError – Not enough arguments.

  • ValueError – No matched filebox.

返回

namedtuple for (‘id’, ‘pipeline_id’, ‘title’)

返回类型

tuple[FileBoxCategoryInfo]

get_pipelines(*filters)

Get piplines from database.

参数

*filters (FilterList) – Filter to get pipeline.

返回

namedtuple for (‘id’, ‘name’, ‘module’)

返回类型

tuple[PipelineInfo]

get_software(name)

Get software path for this database.

参数

name (text_type) – Software name.

返回

Path set in 系统设置 -> 软件设置.

返回类型

path

module(name, module_type='task')[源代码]

Get module in the database.

modules()

All modules in this database.

返回

Modules

返回类型

tuple[Module]

set_data(key, value, is_user=True)

Set additional data in this database.

参数
  • key (text_type) – Data key.

  • value (text_type) – Data value

  • is_user (bool, optional) – Defaults to True.

  • is_user is True, this data will be user specific. (If) –

property token

User token.

class cgtwq.Field[源代码]

Data base field name for filter.

contains(value)[源代码]

Represents value in data item list.

has(value)[源代码]

Represents data has value in it.

in_(value)[源代码]

Represents matched data in value list.

in_namespace(namespace)[源代码]

Get a new Field instance in the namespace.

参数

namespace (str) – Default namespace for keys.

返回

Field

class cgtwq.Filter(key, value, operator=None)[源代码]

CGTeamWork style filter.

classmethod from_list(obj)[源代码]

Create filter instance from a list.

参数

obj (list) – A list match [key, operater, value].

引发

ValueError – can not convert obj to filter.

返回

Filter

in_namespace(namespace)[源代码]

Get a new Filter instance in the namespace.

参数

namespace (str) – Default namespace for keys.

返回

Filter

class cgtwq.FilterList(list_)[源代码]

CGTeamWork style filter list.

classmethod from_arbitrary_args(*filters)[源代码]

Create filterlist from arbitrary arguments.

返回

FilterList

in_namespace(namespace)[源代码]

Create new FilterList instance in the namespace.

参数

namespace (str) – Default namespace for keys.

返回

FilterList

class cgtwq.Message[源代码]

CGTeamWork style message, support image.

dumps()[源代码]

Dump data to string in server defined format.

classmethod load(data)[源代码]

Create message from data.

upload_images(folder, token)[源代码]

Upload contianed images to server. will replace items in self.image.

class cgtwq.Module(name, database, module_type='task')[源代码]

Module(Database table) in database.

call(*args, **kwargs)[源代码]

Call on this module.

count(*filters, **kwargs)[源代码]

Count matched entity in database.

参数
  • \*filters (FilterList, Filter) – Filters for server.

  • **kwargs – namespace (str, optional): Default field namespace.

返回

Count value.

返回类型

int

count_history(filters)

Count history records in the module.

参数

filters (Filter or FilterList) – History filters.

返回

Records count.

返回类型

int

create(kwargs=None, **data)[源代码]

Create entry from data.

参数
  • kwargs (dict) –

  • Any] (**data[str,) – Data to create a entry.

**data:

namespace (str, optional): Default field namespace.

create_field(sign, type_, name=None, label=None)

Create new field in the module.

参数
  • sign (str) – Field sign

  • type_ (str) – Field type, see core.FIELD_TYPES.

  • name (str, optional) – Defaults to None. Field english name.

  • label (str, optional) – Defaults to None. Field chinese name.

delete_field(id_)

Delete field in the module.

参数

id_ (str) – Field id.

distinct(*filters, **kwargs)[源代码]

Get distinct value in the module.

参数
**kwargs:

key: Distinct key, defaults to field of first filter. namespace (str, optional): Default field namespace.

返回

tuple

fields()

Get fields in this module.

filter(*filters, **kwargs)[源代码]

Create selection with filter on this module.

参数
**kwargs:

namespace (str, optional): Default field namespace.

返回

Created selection.

返回类型

Selection

flow()[源代码]

Workflow of the module.

format_field(name)

Formatted field name for this module.

参数

name (text_type) – Short field name.

返回

Full field name, for server.

返回类型

text_type

format_filters(filters)

Format field name in filters.

参数

filters (FilterList, Filter) – Format target.

返回

Formatted filters.

返回类型

FilterList

get_history(filters)
Get history record from the module.

filters (Filter or FilterList): History filters.

返回

History records.

返回类型

tuple[HistoryInfo]

pipelines()[源代码]

All pipeline in this module.

返回

namedtuple for (‘id’, ‘name’, ‘module’).

返回类型

tuple[Pipeline]

select(*id_list)[源代码]

Create selection on this module.

参数

*id_list (text_type) – Id list to select.

返回

Created selection.

返回类型

Selection

property token

User token.

undo_history(history)

Undo a history.

参数

history (HistoryInfo) – History information.

class cgtwq.PluginMeta(uuid)[源代码]

CGTeamWork plug-in metadata.

fetch(token=None)[源代码]

Fetch plugin data from server.

classmethod filter(filters=None, token=None)[源代码]

Filter plugins from server.

参数
  • filters (Filter or FilterList, optional) – Defaults to None. Plugin filter

  • token (str, optional) – Defaults to None. User token.

返回

Matched plug-ins.

返回类型

list[Plugin]

classmethod from_info(info)[源代码]

Initialize Plugin object from info.

参数

info (PluginInfo) – Plugin information.

返回

Plugin

get_argument(key, token=None)[源代码]

Get argument information.

参数
  • key (str) – Argument key.

  • token (str, optional) – Defaults to None. User token.

返回

Plug-in argument information.

返回类型

PluginArgumentInfo

set_argument(key, value=None, description=None, token=None)[源代码]

Set argument data.

参数
  • key (str) – Data key.

  • value (any, optional) – Defaults to None. Data value.

  • description (str, optional) – Defaults to None. Argument description.

  • token (str, optional) – Defaults to None. User token.

set_fields(token=None, **data)[源代码]

Set field data for the plug-in.

参数
  • token (str, optional) – Defaults to None. User token.

  • **data – Field name as key, Value as value.

class cgtwq.ResultSet(roles, data, module)[源代码]

Database query result.

column(field)[源代码]

Get a column from field name.

参数

field (text_type) – Field name.

返回

Column data.

返回类型

tuple

class cgtwq.Entry(module, id_)[源代码]

A selection that only has one item.

get_fields(*fields, **kwargs)[源代码]

Get multiple fields.

返回

Result fields with exactly same order with fields.

返回类型

tuple

related(*filters)[源代码]

Select related entries.

参数

*filters – Pipeline filters.

返回

Selection

class cgtwq.Selection(module, *id_list)[源代码]

Selection with all feature.

引发

EmptySelection – when selection size is 0.

call(*args, **kwargs)[源代码]

Call on this selection.

count(*filters)[源代码]

Count matched entity in the selection.

参数

*filters (Filter,FilterList) – Filters.

返回

Count value.

返回类型

int

delete()[源代码]

Delete the selected item on database.

distinct(*filters, **kwargs)[源代码]

Get distinct value in the selection.

参数
**kwargs:

key: Distinct key, defaults to field of first filter.

返回

tuple

filter(*filters)[源代码]

Filter selection again.

参数

*filters (Filter,FilterList) – Additional filters.

返回

Filtered selection.

返回类型

Selection

classmethod from_data(**kwargs)[源代码]

Get selection from dictionary-like data.

参数

**kwargs – database(str): Database name. module(str): Module name. module_type(str): Module type. id_list(list): Id list.

get_fields(*fields, **kwargs)[源代码]

Get field information for the selection.

参数
  • *fields – Server defined field sign.

  • **kwargs

**kwargs:

namespace (str, optional): Default namespace for key.

返回

Optimized tuple object contains fields data.

返回类型

ResultSet

get_folder(*sign_list)[源代码]

Get signed folder path.

参数

sign_list (six.text_type) – Sign name defined in CGTeemWork: 项目设置 -> 目录文件 -> 标识

返回

Server returned path dictionary.

id as key, path as value.

返回类型

dict

get_image(field='image')

Get imageinfo used on the field.

参数

field (six.text_type) – Defaults to ‘image’, Server defined field name,

返回

Image information.

返回类型

set[ImageInfo]

has_permission_on_status(field)

Return if user has permission to edit field.

参数

field (str) – Field name.

返回

bool

set_fields(kwargs=None, **data)[源代码]

Set field data for the selection.

参数
  • kwargs (dict) –

  • **data – Field name as key, Value as value.

kwargs:

namespace (str, optional): Default namespace for key.

set_image(path, field='image')

Set image for the field.

参数
  • field (six.text_type) – Defaults to ‘image’, Server defined field name,

  • path (six.text_type) – File path.

返回

Uploaded image.

返回类型

ImageInfo

submit(pathnames=(), filenames=(), note='')

Submit file to task, then change status to Check.

参数
  • pathnames (tuple, optional) – Defaults to (). Server pathnames.

  • filenames (tuple, optional) – Defaults to (). Local filenames.

  • note (str, optional) – Defaults to “”. Submit note.

to_entries()[源代码]

Convert selection to entries.

返回

Entries.

返回类型

tuple[Entry]

to_entry()[源代码]

Convert selection to one entry.

引发

ValueError – Not exactly one selected item.

返回

Entry.

返回类型

Entry

property token

User token.

exception cgtwq.AccountError(owner='', current='')[源代码]

Indicate account not match.

exception cgtwq.AccountNotFoundError[源代码]

Indicate account not found.

exception cgtwq.CGTeamWorkException[源代码]

Base exception class for CGTeamWork.

exception cgtwq.IDError[源代码]

Indicate can’t specify shot id on cgtw.

exception cgtwq.LoginError[源代码]

Indicate not logged in.

exception cgtwq.PasswordError[源代码]

Indicate password not correct.

exception cgtwq.PermissionError[源代码]

Indicate sufficient permission.

exception cgtwq.PrefixError[源代码]

Indicate no shot match the prefix.

exception cgtwq.SignError[源代码]

Indicate can’t found matched sign.

exception cgtwq.EmptySelection[源代码]

Indicate no entry match the criteria.