Represents a Python module model used in the application. Attributes: module (str): The name of the module. base_path (str): The base path where the module is located. update_schedule (CrontabSchedule): The schedule for updating the module. update_task (Peri
| 104 | |
| 105 | |
| 106 | class PythonModule(models.Model): |
| 107 | """ |
| 108 | Represents a Python module model used in the application. |
| 109 | |
| 110 | Attributes: |
| 111 | module (str): The name of the module. |
| 112 | base_path (str): The base path where the module is located. |
| 113 | update_schedule (CrontabSchedule): The schedule for updating the module. |
| 114 | update_task (PeriodicTask): The task associated with updating the module. |
| 115 | health_check_schedule (CrontabSchedule): The schedule for health checks. |
| 116 | """ |
| 117 | |
| 118 | module = models.CharField(max_length=120, db_index=True) |
| 119 | base_path = models.CharField(max_length=120, db_index=True, choices=PythonModuleBasePaths.choices) |
| 120 | update_schedule = models.ForeignKey( |
| 121 | CrontabSchedule, |
| 122 | on_delete=models.SET_NULL, |
| 123 | null=True, |
| 124 | blank=True, |
| 125 | related_name="update_for_%(class)s", |
| 126 | ) |
| 127 | update_task = models.OneToOneField( |
| 128 | PeriodicTask, |
| 129 | on_delete=models.SET_NULL, |
| 130 | null=True, |
| 131 | blank=True, |
| 132 | related_name="update_for_%(class)s", |
| 133 | editable=False, |
| 134 | ) |
| 135 | |
| 136 | health_check_schedule = models.ForeignKey( |
| 137 | CrontabSchedule, |
| 138 | on_delete=models.SET_NULL, |
| 139 | null=True, |
| 140 | blank=True, |
| 141 | related_name="healthcheck_for_%(class)s", |
| 142 | ) |
| 143 | |
| 144 | class Meta: |
| 145 | unique_together = [["module", "base_path"]] |
| 146 | ordering = ["base_path", "module"] |
| 147 | |
| 148 | def __str__(self): |
| 149 | return self.module |
| 150 | |
| 151 | def __contains__(self, item: str): |
| 152 | """ |
| 153 | Check if a string or PythonConfig is in the module. |
| 154 | |
| 155 | Args: |
| 156 | item (str or PythonConfig): The item to check. |
| 157 | |
| 158 | Returns: |
| 159 | bool: True if the item is in the module, False otherwise. |
| 160 | """ |
| 161 | if not isinstance(item, str) and not isinstance(item, PythonConfig): |
| 162 | raise TypeError(f"{self.__class__.__name__} needs a string or pythonConfig") |
| 163 | if isinstance(item, str): |
no outgoing calls