accsyn_api.session

class accsyn_api.session.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

JSON serialiser.

default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
__init__(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]

Constructor for JSONEncoder, with sensible defaults.

If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.

If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.

If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an OverflowError). Otherwise, no such check takes place.

If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.

If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.

If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.

If specified, separators should be an (item_separator, key_separator) tuple. The default is (‘, ‘, ‘: ‘) if indent is None and (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.

If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a TypeError.

encode(o)[source]

Return a JSON string representation of a Python data structure.

>>> from json.encoder import JSONEncoder
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo": ["bar", "baz"]}'
item_separator = ', '
iterencode(o, _one_shot=False)[source]

Encode the given object and yield each string representation as available.

For example:

for chunk in JSONEncoder().iterencode(bigobject):
    mysocket.write(chunk)
key_separator = ': '
class accsyn_api.session.JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)[source]

JSON deserialize.

decode(json_string)[source]

Return the Python representation of s (a str instance containing a JSON document).

__init__(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)[source]

object_hook, if specified, will be called with the result of every JSON object decoded and its return value will be used in place of the given dict. This can be used to provide custom deserializations (e.g. to support JSON-RPC class hinting).

object_pairs_hook, if specified will be called with the result of every JSON object decoded with an ordered list of pairs. The return value of object_pairs_hook will be used instead of the dict. This feature can be used to implement custom decoders. If object_hook is also defined, the object_pairs_hook takes priority.

parse_float, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).

parse_int, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).

parse_constant, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered.

If strict is false (true is the default), then control characters will be allowed inside strings. Control characters in this context are those with character codes in the 0-31 range, including '\t' (tab), '\n', '\r' and '\0'.

raw_decode(s, idx=0)[source]

Decode a JSON document from s (a str beginning with a JSON document) and return a 2-tuple of the Python representation and the index in s where the document ended.

This can be used to decode a JSON document from a string that may have extraneous data at the end.

class accsyn_api.session.Session(domain=None, username=None, api_key=None, hostname=None, port=None, proxy=None, verbose=False, pretty_json=False, dev=False, path_logfile=None, timeout=None, connect_timeout=None)[source]

accsyn API session object.

DEFAULT_CONNECT_TIMEOUT = 10
DEFAULT_TIMEOUT = 120
property username
property timeout
property connect_timeout
__init__(domain=None, username=None, api_key=None, hostname=None, port=None, proxy=None, verbose=False, pretty_json=False, dev=False, path_logfile=None, timeout=None, connect_timeout=None)[source]

Initiate a new API session object. Throws exception upon authentication failure.

Parameters
  • domain – The accsyn domain (or read from ACCSYN_DOMAIN environment variable)

  • username – The accsyn username (or read from ACCSYN_API_USER environment variable)

  • api_key – The secret API key for authentication (or read from ACCSYN_API_KEY environment variable)

  • hostname – Override hostname/IP to connect to.

  • port – Override default port 443.

  • proxy – The proxy settings (or read from ACCSYN_PROXY environment variable).

  • verbose – Create a verbose session, printing debug output to stdout.

  • pretty_json – (verbose) Print pretty formatted JSON.

  • dev – Dev mode.

  • path_logfile – Output all log messages to this logfile instead of stdout.

  • timeout – Timeout in seconds for API calls - waiting for response.

  • connect_timeout – Timeout in seconds for API calls - waiting for connection.

static get_hostname()[source]
Returns

The hostname of this computer.

static str(d, indent=4)[source]

Return a string representation of a dict

get_last_message()[source]

Retreive error message from last API call.

login()[source]

Attempt to login to accsyn and get a session.

create(entitytype, data, entitytype_id=None, allow_duplicates=True)[source]

Create a new accsyn entity.

Parameters
  • entitytype – The type of entity to create (job, share, acl)

  • data – The entity data as a dictionary.

  • entitytype_id – For creating sub entities (tasks), this is the parent (job) id.

  • allow_duplicates – (jobs and tasks) Allow duplicates to be created.

Returns

The created entity data, as dictionary.

find(query, attributes=None, finished=None, offline=None, archived=None, limit=None, skip=None, create=False, update=False)[source]

Return (GET) a list of entities/entitytypes/attributes based on query.

Parameters
  • query – The query, a string on accsyn query format.

  • attributes – The attributes to return, default is to return all attributes with access.

  • finished – (job) Search among inactive jobs.

  • offline – (user,share) Search among offline entities.

  • archived – Search among archived (deleted/purged) entities.

  • limit – The maximum amount of entities to return.

  • skip – The amount of entities to skip.

  • create – (attributes) Return create (POST) attributes.

  • update – (attributes) Return update (PUT) attributes.

Returns

List of dictionaries.

find_one(query, attributes=None, finished=None, offline=None, archived=None)[source]

Return a single entity.

Parameters
  • query – The query, a string on accsyn query format.

  • attributes – The attributes to return, default is to return all attributes with access.

  • finished – (job) Search among inactive jobs.

  • offline – (user,share) Search among offline entities.

  • archived – Search among archived (purged/deleted) entities.

Returns

If found, a single dictionary. None otherwise.

report(query)[source]

(Support) Return an internal backend report of an entity.

Parameters

query – The query, a string on accsyn query format.

Returns

A text string containing the human readable report.

metrics(query, attributes=['speed'], time=None)[source]

Return metrics for an entity (job)

New in version 2.0.

Parameters
  • query

  • attributes

  • time

Returns

update(entitytype, entityid, data)[source]

Update/modify an entity.

Parameters
  • entitytype – The type of entity to update (job, share, acl, ..)

  • entityid – The id of the entity.

  • data – The dictionary containing attributes to update.

Returns

The updated entity data, as dictionary.

update_one(entitytype, entityid, data)[source]

Update/modify an entity.

Parameters
  • entitytype – The type of entity to update (job, share, acl, ..)

  • entityid – The id of the entity.

  • data – The dictionary containing attributes to update.

Returns

The updated entity data, as dictionary

Deprecated since version 2.0.2: Since Python 2.0.2 you should use the update() function instead

update_many(entitytype, data, entityid)[source]

Update/modify multiple entities - tasks beneath a job.

Parameters
  • entitytype – The type of parent entity to update (job)

  • data – The list dictionaries containing sub entity (task) id and attributes to update.

  • entityid – The id of the parent entity to update (job)

Returns

The updated sub entities (tasks), as dictionaries.

Deprecated since version 2.0.2: Since Python 2.0.2 you should use the update() function instead

assign(entitytype_parent, entitytype_child, data)[source]

Assign one entity to another.

New in version 2.0.

Parameters
  • entitytype_parent – The parent entity type to assign child entity to.

  • entitytype_child – The child entity type to assign to parent entity.

  • data – Assignment data, should contain parent and child entity ids.

Returns

True if assignment was a success, exception otherwise.

assignments(entitytype, entityid)[source]

Return list of assigned child entities.

New in version 2.0.

Parameters

query

Returns

List of dictionaries.

deassign(entitytype_parent, entitytype_child, data)[source]

De-assign one entity from another.

New in version 2.0.

Parameters
  • entitytype_parent – The parent entity type to deassign child entity from

  • entitytype_child – The child entity type to deassign from parent entity

  • data – De-assignment data, should contain parent and child entity ids + additional information as required

Returns

True if deassignment was a success, exception otherwise.

offline_one(entitytype, entityid)[source]

Offline an entity.

New in version 2.0.

Parameters
  • entitytype – The type of entity to delete (job, share, acl, ..)

  • entityid – The id of the entity.

Returns

True if offline, an exception is thrown otherwise.

delete_one(entitytype, entityid)[source]

Delete(archive) an entity.

Parameters
  • entitytype – The type of entity to delete (job, share, acl, ..)

  • entityid – The id of the entity.

Returns

True if deleted, an exception is thrown otherwise.

ls(path, recursive=False, maxdepth=None, getsize=False, files_only=False, directories_only=False, include=None, exclude=None)[source]

List files on a share.

Parameters
  • path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’

  • recursive – If True - a recursive listing will be performed.

  • maxdepth – (Recursive) The maximum depth to descend.

  • getsize – If True - file sizes will be returned.

  • files_only – If True - only return files, no directories.

  • directories_only – If True - only return directories, no files.

  • include – Filter expression (string or list) dictating what to include in result: “word” - exact match, “word” - ends with word, “word” - starts with word, “word” - contains word, “start*end” - starts & ends with word and “re(‘…’)” - regular expression. Has precedence over exclude.

  • exclude – Filter expression (string or list) dictating what to exclude from result: “word” - exact match, “word” - ends with word, “word” - starts with word, “word” - contains word, “start*end” - starts & ends with word and “re(‘…’)” - regular expression.

Returns

A dictionary containing result of file listing.

Include and exclude filters are case-insensitive, to make regular expression case-sensitive, use the following syntax: “re(‘…’, ‘I’)”.

New in version 2.2.0: (app/daemon: 2.6-20)

getsize(path, include=None, exclude=None)[source]

Get size of a file or directory.

Parameters
  • path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.

  • include – Filter expression (string or list) dictating what to include in result: “word” - exact match, “word” - ends with word, “word” - starts with word, “word” - contains word, “start*end” - starts & ends with word and “re(‘…’)” - regular expression. Has precedence over exclude.

  • exclude – Filter expression (string or list) dictating what to exclude from result: “word” - exact match, “word” - ends with word, “word” - starts with word, “word” - contains word, “start*end” - starts & ends with word and “re(‘…’)” - regular expression.

Returns

A dictionary containing result of file listing.

Include and exclude filters are case-insensitive, to make regular expression case-sensitive, use the following syntax: “re(‘…’, ‘I’)”.

New in version 2.2.0: (app/daemon: 2.6-20)

exists(path)[source]

Check if a file or directory exists.

Parameters

path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.

Returns

True if file exists, False otherwise.

mkdir(path)[source]

Create a directory on a share.

New in version 2.0.

Parameters

path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.

Returns

True if file exists, False otherwise.

rename(path, path_to)[source]

Rename a file/directory on a share.

New in version 2.0.

Parameters
  • path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.

  • path_to – The new accsyn path, has to be within the same directory as source path, on the form ‘share=<the share>/<path>/<somewhere>’.

Returns

True if file exists, False otherwise.

mv(path_src, path_dst)[source]

Move a file/directory on a share.

New in version 2.0.

Parameters
  • path_src – The accsyn source path, on the form ‘share=<the share>/<path>/<somewhere>’.

  • path_dst – The accsyn destination path, on the form ‘share=<the share>/<path>/<somewhere>’.

Returns

True if file exists, False otherwise.

rm(path)[source]

Remove a file/directory on a share.

New in version 2.0.

Parameters

path – The accsyn path, on the form ‘share=<the share>/<path>/<somewhere>’.

Returns

True if file exists, False otherwise.

prepublish(data)[source]

Pre-process a publish.

Parameters

data – The pre publish data, see documentation.

Returns

Processed publish data, see documentation.

get_setting(name=None, scope='workspace', entity_id=None, integration=None, data=None)[source]

Retrive name setting for the given scope (workspace, job, share..), for optional entity_id or integration (ftrack,..)

set_setting(name, value, scope='workspace', entity_id=None, integration=None, data=None)[source]

Set the setting identified by name to value for entity_id within scope.

get_api_key()[source]

Fetch API key, by default disabled in backend.

gui_is_running()[source]

Backward compability

app_is_running()[source]

Check if the accsyn desktop app is running on the same machine (code/hostname match) and with same user ID.

Equivalent to do client query with user, code and type.

Returns

True if found, False otherwise.

server_is_running()[source]

Backward compatibility

daemon_is_running()[source]

Check if a daemon is running on the same machine (code/hostname match) with same user ID.

Equivalent to do client query with user, code and type.

Returns

True if found, False otherwise.

integration(name, operation, data)[source]

Make an integration utility call for integration pointed out by name and providing the operation as string and data as a dictionary

help()[source]
decode_query(query)[source]
exception accsyn_api.session.AccsynException(message)[source]
args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

__init__(message)[source]