threads.workers#

Defines bookmarks.threads.workers.BaseWorker, the main thread worker base class, and various other helper functions.

Classes:

BaseWorker(queue[, parent])

Base worker class used to load and process item data.

InfoWorker(queue[, parent])

A worker used to retrieve file information.

ShotgunWorker(queue[, parent])

This worker is used to retrieve data from ShotGrid.

ThumbnailWorker(queue[, parent])

Thread worker responsible for creating and loading thumbnails.

TransactionsWorker(queue[, parent])

This worker processes database transactions.

Functions:

count_assets(path, ASSET_IDENTIFIER)

Get the number of asset items.

count_todos(asset_row_data)

Get the number of TODO items.

get_bookmark_description(bookmark_row_data)

Utility method for constructing a short description for a bookmark item.

get_ranges(arr, padding)

Given an array of numbers the method will return a string representation of the ranges contained in the array.

process(func)

Decorator for worker process_data slots.

update_shotgun_configured(pp, b, a, ref)

Slot called when a shotgun integration value was updated.

update_slack_configured(source_paths, ...)

Slot called when a slack integration value was updated.

verify_thread_affinity()

Prohibits running methods from the main gui thread.

class bookmarks.threads.workers.BaseWorker(queue, parent=None)[source]#

Bases: QObject

Base worker class used to load and process item data.

Each worker is associated with a thread controller and a data queue. See bookmarks.threads.threads for the definitions.

Methods:

clear_queue()

Slot called by the resetQueue signal and is responsible for clearing the worker's queue.

init_worker()

Initialize the queue timer when the worker has been moved to the correct thread.

queue_items(refs)

Queues the given list of weakrefs to the workers' associated queue.

queue_model(data_type_ref1, data_type_ref2)

Queues the data items of the given list model.

update_changed_database_value(table, source, ...)

Process changes when any bookmark database value changes.

Attributes:

startTimer(*args, **kwargs)

clear_queue()[source]#

Slot called by the resetQueue signal and is responsible for clearing the worker’s queue.

init_worker()[source]#

Initialize the queue timer when the worker has been moved to the correct thread.

queue_items(refs)[source]#

Queues the given list of weakrefs to the workers’ associated queue.

Parameters:

refs (list or tuple) – A list of weakref.ref instances.

queue_model(data_type_ref1, data_type_ref2)[source]#

Queues the data items of the given list model.

This method is used by the file item model and queues individual files and collapsed sequence items of the given model.

update_changed_database_value(table, source, key, value)[source]#

Process changes when any bookmark database value changes.

Parameters:
  • tab_type (idx) – A tab type used to match the slot with the model type.

  • source (str) – A file path.

  • role (int) – An item role.

  • v (object) – The value to set.

Returns:

Description of returned object.

Return type:

type

startTimer(*args, **kwargs)#
class bookmarks.threads.workers.InfoWorker(queue, parent=None)[source]#

Bases: BaseWorker

A worker used to retrieve file information.

We will query the file system for file size, and the bookmark database for the description, and file flags.

Methods:

process_data(ref)

Populates the item with the missing file information.

process_data(ref)[source]#

Populates the item with the missing file information.

Parameters:

ref (weakref) – An internal model data item’s weakref.

Returns:

True on success, False otherwise.

Return type:

bool

class bookmarks.threads.workers.ShotgunWorker(queue, parent=None)[source]#

Bases: BaseWorker

This worker is used to retrieve data from ShotGrid.

class bookmarks.threads.workers.ThumbnailWorker(queue, parent=None)[source]#

Bases: BaseWorker

Thread worker responsible for creating and loading thumbnails.

The resulting image data is saved in the ImageCache and used by the item delegates to paint thumbnails.

Methods:

process_data(ref)

Populates the ImageCache with an existing thumbnail or generates a new one if ref refers to a file understood by OpenImageIO.

queue_items(refs)

Queues the given list of weakrefs to the workers' associated queue.

process_data(ref)[source]#

Populates the ImageCache with an existing thumbnail or generates a new one if ref refers to a file understood by OpenImageIO.

If the return value is not None, the model will request a repaint event for the row the ref corresponds to. See the @process decorator for details.

Parameters:

ref (weakref.ref) – A weakref to a data segment.

Returns:

ref if loaded successfully, else None.

Return type:

ref or None

queue_items(refs)[source]#

Queues the given list of weakrefs to the workers’ associated queue.

Parameters:

refs (list or tuple) – A list of weakref.ref instances.

class bookmarks.threads.workers.TransactionsWorker(queue, parent=None)[source]#

Bases: BaseWorker

This worker processes database transactions.

bookmarks.threads.workers.count_assets(path, ASSET_IDENTIFIER)[source]#

Get the number of asset items.

bookmarks.threads.workers.count_todos(asset_row_data)[source]#

Get the number of TODO items.

bookmarks.threads.workers.get_bookmark_description(bookmark_row_data)[source]#

Utility method for constructing a short description for a bookmark item.

The description includes currently set properties and the description of the bookmark.

Parameters:

bookmark_row_data (dict) – Data retrieved from the database.

Returns:

The description of the bookmark.

Return type:

str

bookmarks.threads.workers.get_ranges(arr, padding)[source]#

Given an array of numbers the method will return a string representation of the ranges contained in the array.

Parameters:
  • arr (list) – An array of numbers.

  • padding (int) – The number of leading zeros before the number.

Returns:

A string representation of the given array.

Return type:

str

bookmarks.threads.workers.process(func)[source]#

Decorator for worker process_data slots.

Takes and passes the next available data in the queue for processing and emits the refUpdated signal if the data has been correctly loaded.

bookmarks.threads.workers.update_shotgun_configured(pp, b, a, ref)[source]#

Slot called when a shotgun integration value was updated.

bookmarks.threads.workers.update_slack_configured(source_paths, bookmark_row_data, ref)[source]#

Slot called when a slack integration value was updated.

bookmarks.threads.workers.verify_thread_affinity()[source]#

Prohibits running methods from the main gui thread.

Raises:

RuntimeError – If the calling thread is the main gui thread.