dicogis.ui.workers module

Name:

Workers

Purpose:

QThread-based workers running long tasks off the GUI thread, plus a Qt-signal-based implementation of the ProgressReporter protocol.

Author:

Julien Moura (@geojulien)

class dicogis.ui.workers.FolderScanWorker(target_folder, parallel_scan=False, max_workers=None, progress_reporter=None, parent=None)

Bases: QObject

Worker listing geodata files under a folder structure, off the GUI thread.

__init__(target_folder, parallel_scan=False, max_workers=None, progress_reporter=None, parent=None)

Initialize the worker.

Parameters:
  • target_folder (str | Path) – folder to walk into to look for geographic datasets.

  • parallel_scan (bool) – see find_geodata_files()’ parallel_scan argument.

  • max_workers (int | None) – see find_geodata_files()’ max_workers argument.

  • progress_reporter (ProgressReporter | None) – see find_geodata_files()’ progress_reporter argument. Also what makes the scan cancellable.

  • parent (QObject | None) – Qt parent object.

canceled
error
finished
run()

Run the folder scan and emit the resulting lists of files.

Return type:

None

status_message
class dicogis.ui.workers.PostgisProcessingWorker(sgbd_reader, serializer, progress_reporter=None, parent=None)

Bases: QObject

Worker processing PostGIS tables/views, off the GUI thread.

__init__(sgbd_reader, serializer, progress_reporter=None, parent=None)

Initialize the worker.

Parameters:
canceled
error
finished
run()

Iterate over PostGIS layers, serialize their metadata and emit progress.

Return type:

None

class dicogis.ui.workers.ProcessingWorker(processor, parent=None)

Bases: QObject

Worker processing a queue of geodata files, off the GUI thread.

__init__(processor, parent=None)

Initialize the worker.

Parameters:
  • processor (ProcessingFiles) – pre-configured files processor to run. It’s cancelled through the progress reporter it was built with.

  • parent (QObject | None) – Qt parent object.

canceled
error
finished
run()

Run the files processing and emit the total number of files processed.

Return type:

None

class dicogis.ui.workers.PublishWorker(input_folder, udata_api_key, udata_api_url_base, udata_api_version, udata_organization_id=None, parent=None)

Bases: QObject

Worker publishing DicoGIS metadata JSON files to a uData catalog, off the GUI thread.

__init__(input_folder, udata_api_key, udata_api_url_base, udata_api_version, udata_organization_id=None, parent=None)

Initialize the worker.

Parameters:
  • input_folder (Path) – folder where metadata JSON files (udata flavor) are stored.

  • udata_api_key (str) – API key of the account on the uData instance.

  • udata_api_url_base (str) – API URL of the uData instance.

  • udata_api_version (str) – API version of the uData instance.

  • udata_organization_id (str | None) – organization ID in the uData instance. Defaults to None.

  • parent (QObject | None) – Qt parent object.

error
finished
progress_changed
run()

Run the publication and emit the resulting report.

Return type:

None

class dicogis.ui.workers.QtProgressReporter(parent=None)

Bases: QObject

Qt-signal-based implementation of the ProgressReporter protocol.

Safe to instanciate and drive from a worker thread: signals emitted here are delivered to slots connected from the GUI thread through Qt’s automatic cross-thread queued connections.

__init__(parent=None)

Initialize the progress reporter.

increment(amount=1)

Increment the progress counter.

Return type:

None

is_canceled()

Whether a cancellation has been requested.

Return type:

bool

message_changed
progress_incremented
request_cancel()

Ask the running operation to stop at its next cancellation check.

Called from the GUI thread (a cancel button); the operation itself polls is_canceled() from its own thread(s), hence the Event.

Return type:

None

set_message(message)

Update the currently displayed status message.

Return type:

None

set_total(total)

Set the total/maximum value of the progress counter.

Return type:

None

total_changed