threads.workers#
Defines bookmarks.threads.workers.BaseWorker
, the main thread worker base
class, and various other helper functions.
Classes:
|
Base worker class used to load and process item data. |
|
A worker used to retrieve file information. |
|
This worker is used to retrieve data from ShotGrid. |
|
Thread worker responsible for creating and loading thumbnails. |
|
This worker processes database transactions. |
Functions:
|
Get the number of asset items. |
|
Get the number of TODO items. |
|
Utility method for constructing a short description for a bookmark item. |
|
Given an array of numbers the method will return a string representation of the ranges contained in the array. |
|
Decorator for worker process_data slots. |
|
Slot called when a shotgun integration value was updated. |
|
Slot called when a slack integration value was updated. |
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:
Slot called by the resetQueue signal and is responsible for clearing the worker's queue.
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.
- 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
- 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.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.