spinetoolbox.spine_io.connection_manager

Contains ConnectionManager class.

author:
  1. Vennström (VTT)
date:

1.6.2019

Module Contents

Classes

ConnectionManager Class to manage data connections in another thread.
ConnectionWorker A class for delegating SourceConnection operations to another QThread.
class spinetoolbox.spine_io.connection_manager.ConnectionManager(connection, connection_settings, parent=None)[source]

Bases: PySide2.QtCore.QObject

Class to manage data connections in another thread.

Parameters:connection (class) – A class derived from SourceConnection, e.g. CSVConnector
start_table_get[source]
start_data_get[source]
start_mapped_data_get[source]
connection_failed[source]
connection_ready[source]
connection_closed[source]
error[source]
fetching_data[source]
data_ready[source]
tables_ready[source]
mapped_data_ready[source]
current_table_changed[source]

Emitted when the current table has changed.

connection[source]
current_table[source]
is_connected[source]
table_options[source]
table_types[source]
table_row_types[source]
source[source]
source_type[source]
set_table(self, table)[source]

Sets the current table of the data source.

Parameters:table (str) – table name
request_tables(self)[source]

Get tables tables from source, emits two singals, fetchingData: ConnectionManager is busy waiting for data startTableGet: a signal that the worker in another thread is listening to know when to run get a list of table names.

request_data(self, table=None, max_rows=-1)[source]

Request data from emits dataReady to with data

Keyword Arguments:
 
  • {str} -- which table to get data from (default (table) – {None})
  • {int} -- how many rows to read (default (max_rows) – {-1})
request_mapped_data(self, table_mappings, max_rows=-1)[source]

Get mapped data from csv file

Parameters:{dict} -- dict with filename as key and a list of mappings as value (table_mappings) –
Keyword Arguments:
 {int} -- number of rows to read, if -1 read all rows (default (max_rows) – {-1})
connection_ui(self)[source]

launches a modal ui that prompts the user to select source.

ex: fileselect if source is a file.

init_connection(self)[source]

Creates a Worker and a new thread to read source data. If there is an existing thread close that one.

_handle_connection_ready(self)[source]
_handle_tables_ready(self, table_options)[source]
update_options(self, options)[source]
get_current_options(self)[source]
get_current_option_value(self, option_key)[source]

Returns the value for option_key for the current table or the default value.

set_table_options(self, options)[source]

Sets connection manager options for current connector

Parameters:options (dict) – settings for the tables
set_table_types(self, types)[source]

Sets connection manager types for current connector

Parameters:types (dict) – dict with types settings, column (int) as key, type as value
set_table_row_types(self, types)[source]

Sets connection manager types for current connector

Parameters:{dict} -- Dict with types settings, row (types) –
close_connection(self)[source]

Closes and deletes thread and worker

class spinetoolbox.spine_io.connection_manager.ConnectionWorker(source, connection, connection_settings, parent=None)[source]

Bases: PySide2.QtCore.QObject

A class for delegating SourceConnection operations to another QThread.

Parameters:
  • source (str) – path of the source file
  • connection (class) – A class derived from SourceConnection for connecting to the source file
connectionFailed[source]
error[source]
connectionReady[source]
tablesReady[source]
dataReady[source]
mappedDataReady[source]
init_connection(self)[source]

Connect to data source

tables(self)[source]
data(self, table, options, max_rows)[source]
mapped_data(self, table_mappings, options, types, table_row_types, max_rows)[source]
disconnect(self)[source]