models

class eztaskmanager.models.AppCommand(*args, **kwargs)[source]

An application command representation.

Parameters:
  • id (BigAutoField) – Id

  • name (CharField) – Name

  • app_name (CharField) – App name

  • active (BooleanField) – Active

name

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

app_name

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

active

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

get_command_class()[source]

Get the command class.

property help_text

Get the command help text.

exception DoesNotExist
exception MultipleObjectsReturned
id

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

objects = <django.db.models.manager.Manager object>
task_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class eztaskmanager.models.LaunchReport(*args, **kwargs)[source]

A report of a task execution with log.

Parameters:
  • id (BigAutoField) – Id

  • task_id (ForeignKey) – Task

  • invocation_result (CharField) – Invocation result

  • invocation_datetime (DateTimeField) – Invocation datetime

RESULT_NO = ''
RESULT_OK = 'ok'
RESULT_FAILED = 'failed'
RESULT_ERRORS = 'errors'
RESULT_WARNINGS = 'warnings'
RESULT_CHOICES = (('', '---'), ('ok', 'OK'), ('failed', 'FAILED'), ('errors', 'ERRORS'), ('warnings', 'WARNINGS'))
task

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

invocation_result

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

invocation_datetime

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

classmethod get_notification_handlers()[source]

Get the list of notification handlers to send the report to.

get_log_lines()[source]

Format the log entries, here is an example.

read_log_lines(offset: int)[source]

Use an offset to read lines of the llog related to the report (self) starting from the offset.

param:

offset lines to start from

return:

2-tuple (list, int) - list of lines of log records from offset - the number of total lines

log_tail(n_lines=10)[source]

Return the last lines of the logs of a launch_report.

property n_log_lines

Return the number of log lines for this report.

property n_log_errors

Return the number of errors in this report.

property n_log_warnings

Return the number of warnings in this report.

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

Refresh the task cache after deleting this report.

exception DoesNotExist
exception MultipleObjectsReturned
get_invocation_result_display(*, field=<django.db.models.fields.CharField: invocation_result>)
get_next_by_invocation_datetime(*, field=<django.db.models.fields.DateTimeField: invocation_datetime>, is_next=True, **kwargs)
get_previous_by_invocation_datetime(*, field=<django.db.models.fields.DateTimeField: invocation_datetime>, 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.

logs

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
task_id
class eztaskmanager.models.Log(*args, **kwargs)[source]

The log generated by a report.

Parameters:
  • id (BigAutoField) – Id

  • launch_report_id (ForeignKey) – Launch report

  • timestamp (DateTimeField) – Timestamp

  • level (CharField) – Level

  • message (TextField) – Message

launch_report

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

timestamp

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

level

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

message

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

exception DoesNotExist
exception MultipleObjectsReturned
get_next_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, is_next=True, **kwargs)
get_previous_by_timestamp(*, field=<django.db.models.fields.DateTimeField: timestamp>, 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.

launch_report_id
objects = <django.db.models.manager.Manager object>
class eztaskmanager.models.TaskCategory(*args, **kwargs)[source]

A task category, used to group tasks when numbers go up.

Parameters:
  • id (BigAutoField) – Id

  • name (CharField) – Name

name

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

exception DoesNotExist
exception MultipleObjectsReturned
id

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

objects = <django.db.models.manager.Manager object>
task_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class eztaskmanager.models.Task(*args, **kwargs)[source]

A command related task.

Represents a management command with a defined set of arguments (

Parameters:
  • id (BigAutoField) – Id

  • name (CharField) – Name

  • command_id (ForeignKey) – Command

  • arguments (TextField) – Separate arguments with a comma “,”and parameters with a blank space “ “. eg: -f, –secondarg param1 param2, –thirdarg=pippo, –thirdarg

  • category_id (ForeignKey) – Choose a category for this task

  • status (CharField) – Status

  • scheduling (DateTimeField) – Initial scheduling

  • repetition_period (CharField) – Repetition period

  • repetition_rate (PositiveSmallIntegerField) – Repetition rate

  • note (TextField) – A note on how this task is used.

  • scheduled_job_id (CharField) – A unique identifier for the scheduled job, if any

  • cached_last_invocation_datetime (DateTimeField) – Last datetime

  • cached_last_invocation_result (CharField) – Last result

  • cached_last_invocation_n_errors (PositiveIntegerField) – Errors

  • cached_last_invocation_n_warnings (PositiveIntegerField) – Warnings

  • cached_next_ride (DateTimeField) – Next execution time

REPETITION_PERIOD_MINUTE = 'minute'
REPETITION_PERIOD_HOUR = 'hour'
REPETITION_PERIOD_DAY = 'day'
REPETITION_PERIOD_WEEK = 'week'
REPETITION_PERIOD_MONTH = 'month'
REPETITION_PERIOD_CHOICES = (('minute', 'MINUTE'), ('hour', 'HOUR'), ('day', 'DAY'), ('month', 'MONTH'))
STATUS_IDLE = 'idle'
STATUS_SPOOLED = 'spooled'
STATUS_SCHEDULED = 'scheduled'
STATUS_STARTED = 'started'
STATUS_CHOICES = (('idle', 'IDLE'), ('spooled', 'SPOOLED'), ('scheduled', 'SCHEDULED'), ('started', 'STARTED'))
name

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

command

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

arguments

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

category

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

status

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

scheduling

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

property scheduling_utc

Sho the scheduling time, in UTC.

repetition_period

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

repetition_rate

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

property is_periodic

A periodic task is such only if both repetition period and rate are set.

note

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

scheduled_job_id

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

cached_last_invocation_datetime

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

cached_last_invocation_result

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

cached_last_invocation_n_errors

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

cached_last_invocation_n_warnings

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

cached_next_ride

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

property interval_in_seconds

Returns the interval in seconds based on the repetition period and rate.

Returns:

The interval in seconds.

Return type:

int

Example

# Create an instance of the class obj = MyClass()

# Set the repetition period and rate obj.repetition_period = ‘day’ obj.repetition_rate = 2

# Calculate the interval in seconds result = obj.interval_in_seconds() # Returns 2 * 24 * 60 * 60

property args

Get the task args.

property options

Get the task options.

property complete_args

Returns a list containing all the non-null values from the dictionary of arguments.

Get all task args in order to avoid problems with required options.

Returns:

A list containing non-null argument values.

As suggested here: https://stackoverflow.com/questions/32036562/call-command-argument-is-required

compute_cache()[source]

Compute cached values for this task.

prune_reports(n: int = 5)[source]

Delete all Task’s LaunchReports except latest n.

exception DoesNotExist
exception MultipleObjectsReturned
category_id
command_id
get_cached_last_invocation_result_display(*, field=<django.db.models.fields.CharField: cached_last_invocation_result>)
get_repetition_period_display(*, field=<django.db.models.fields.CharField: repetition_period>)
get_status_display(*, field=<django.db.models.fields.CharField: status>)
id

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

launchreport_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

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