core.models.Daemon module

Module with the Daemon model class.

core.models.Daemon.logger = <Logger core.models.Daemon (INFO)>

The logger instance for this module.

class core.models.Daemon.Daemon(*args, **kwargs)[source]

Bases: ExportModelOperationsMixin('routine'), DirtyFieldsMixin, URLMixin, HealthModelMixin, TimestampModelMixin, Model

Database model for the daemon fetching a mailbox.

Note

The internal name of this object is daemon, the external name for the user interface is routine.

BASENAME = 'daemon'
DELETE_NOTICE = 'This will only delete this routine, not its mailbox.'
DELETE_NOTICE_PLURAL = 'This will only delete these routine, not their mailboxes.'
uuid

The uuid of this daemon. Used to create a unique logfile.

mailbox: ForeignKey

The mailbox this daemon fetches. Unique. Deletion of that mailbox deletes this daemon.

fetching_criterion

The fetching criterion for this mailbox. eonvelope.constants.EmailFetchingCriterionChoices.ALL by default.

fetching_criterion_arg

Additional fetching criterion argument for this mailbox. “” by default.

celery_task: OneToOneField

The periodic celery task wrapped by this daemon.

interval: ForeignKey

The period with which the daemon is running.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

_meta = <Options for Daemon>
celery_task_id
created

The datetime the model instance was created. Is set automatically.

get_fetching_criterion_display(*, field=<django.db.models.fields.CharField: fetching_criterion>)
get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)
get_next_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=True, **kwargs)
get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)
get_previous_by_updated(*, field=<django.db.models.fields.DateTimeField: updated>, is_next=False, **kwargs)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

interval_id
is_healthy

Flags whether the model instance is subject to errors. None by default.

last_error

The latest error in connection with the model instance.

last_error_occurred_at

The time of occurrence of the latest error.

mailbox_id
objects = <django.db.models.manager.Manager object>
updated

The datetime the model instance entry was last updated. Is set automatically.

__str__()[source]

Returns a string representation of the model data.

Return type:

str

Returns:

The string representation of the daemon, using uuid and mailbox.

save(*args, **kwargs)[source]

Extended :django:django.models.Model.save() method.

Return type:

None

Parameters:
delete(*args, **kwargs)[source]
Return type:

tuple[int, dict[str, int]]

Parameters:
clean()[source]

Validates that fetching_criterion is available for the mailbox.account.

Return type:

None

test()[source]

Tests whether the data in the model is correct and the daemons task can be run.

Tests the entire task, including fetching and the celery backend. The core.models.Daemon.is_healthy flag is set accordingly by the task itself.

Raises:

Exception – Any exception raised by the task.

Return type:

None

start()[source]

Start the daemons celery_task.

Return type:

bool

Returns:

Whether the start operation was successful.

stop()[source]

Stops the daemons celery_task.

Return type:

bool

Returns:

Whether the stop operation was successful.