Receivers

Django signal receivers for connection app.

smarter.apps.connection.receivers.handle_api_connection_attempted(sender, connection, **kwargs)[source]

Log an API connection attempt.

Parameters:
  • sender – The class that sent the signal.

  • connection (ApiConnection) – The ApiConnection.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_api_connection_failed(sender, connection, error=None, **kwargs)[source]

Log, at INFO level, that an API connection failed and is not ready.

Parameters:
  • sender – The class that sent the signal.

  • connection (ApiConnection) – The ApiConnection.

  • error (Exception | None) – The exception, if any. It is not logged.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_api_connection_pre_delete(sender, instance, **kwargs)[source]

Log that an ApiConnection is about to be deleted.

Parameters:
  • sender – The class that sent the signal.

  • instance – The ApiConnection being deleted.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_api_connection_query_attempted(sender, connection, **kwargs)[source]

Log an API query attempt.

Parameters:
  • sender – The class that sent the signal.

  • connection (ApiConnection) – The ApiConnection.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_api_connection_query_failed(sender, connection, response=None, error=None, **kwargs)[source]

Log, at INFO level, a failed API query, with its JSON response body and error.

Parameters:
  • sender – The class that sent the signal.

  • connection (ApiConnection) – The ApiConnection.

  • response (Response | None) – The HTTP response, or None.

  • error (Exception | None) – The exception, or None.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_api_connection_query_success(sender, connection, response=None, **kwargs)[source]

Log a successful API query, with its JSON response body.

Parameters:
  • sender – The class that sent the signal.

  • connection (ApiConnection) – The ApiConnection.

  • response (Response | None) – The HTTP response, or None.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_api_connection_saved(sender, instance, created, **kwargs)[source]

Log that an ApiConnection was created or updated, and its whole row at DEBUG level.

Parameters:
  • sender – The class that sent the signal.

  • instance – The ApiConnection that was saved.

  • created – True if the row was created, False if it was updated.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_api_connection_success(sender, connection, **kwargs)[source]

Log that an API connection succeeded and is ready.

Parameters:
  • sender – The class that sent the signal.

  • connection (ApiConnection) – The ApiConnection.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_sql_connection_attempted(sender, connection, **kwargs)[source]

Log a SQL connection attempt, with the masked connection string.

Parameters:
  • sender – The class that sent the signal.

  • connection (SqlConnection) – The SqlConnection.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_sql_connection_failed(sender, connection, error, **kwargs)[source]

Handle SQL connection failed signal.

Only logs the failure: the method that sent the signal reports it to its caller, by returning None. The connection string is always masked, so that its password is never logged.

smarter.apps.connection.receivers.handle_sql_connection_pre_delete(sender, instance, **kwargs)[source]

Log that a SqlConnection is about to be deleted.

Parameters:
  • sender – The class that sent the signal.

  • instance – The SqlConnection being deleted.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_sql_connection_query_attempted(sender, connection, sql, limit, **kwargs)[source]

Log a SQL query attempt, with its SQL and row limit.

Parameters:
  • sender – The class that sent the signal.

  • connection (SqlConnection) – The SqlConnection.

  • sql (str) – The SQL query.

  • limit (int) – The row limit of the query.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_sql_connection_query_failed(sender, connection, sql, limit, error, **kwargs)[source]

Handle SQL connection query failed signal.

Only logs the failure: execute_query(), which sent the signal, reports it to its caller by returning False.

smarter.apps.connection.receivers.handle_sql_connection_query_success(sender, connection, sql, limit, **kwargs)[source]

Log a successful SQL query, with its SQL and row limit.

Parameters:
  • sender – The class that sent the signal.

  • connection (SqlConnection) – The SqlConnection.

  • sql (str) – The SQL query.

  • limit (int) – The row limit of the query.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_sql_connection_saved(sender, instance, created, **kwargs)[source]

Log that a SqlConnection was created or updated, and its whole row at DEBUG level.

Parameters:
  • sender – The class that sent the signal.

  • instance (SqlConnection) – The SqlConnection that was saved.

  • created – True if the row was created, False if it was updated.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_sql_connection_success(sender, connection, **kwargs)[source]

Log that a SQL connection succeeded and is ready.

Parameters:
  • sender – The class that sent the signal.

  • connection (SqlConnection) – The SqlConnection.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.handle_sql_connection_validated(sender, connection, **kwargs)[source]

Log that a SQL connection was validated.

Parameters:
  • sender – The class that sent the signal.

  • connection (SqlConnection) – The SqlConnection.

  • kwargs – Other keyword arguments sent with the signal.

smarter.apps.connection.receivers.masked_dict(dic)[source]

Mask sensitive data in a dictionary.

Return type:

dict[str, Any]