2020-04-14 22:49:22 +00:00
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from typing import Tuple
|
2020-08-04 22:25:02 +00:00
|
|
|
import database
|
2020-04-14 22:49:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Plugin(ABC):
|
|
|
|
models = []
|
|
|
|
|
2020-04-17 16:16:58 +00:00
|
|
|
@abstractmethod
|
|
|
|
def get_interval(self) -> int:
|
|
|
|
pass
|
|
|
|
|
2020-04-14 22:49:22 +00:00
|
|
|
@abstractmethod
|
|
|
|
def execute(self) -> None:
|
|
|
|
pass
|
2020-08-04 22:25:02 +00:00
|
|
|
|
2021-02-08 22:16:52 +00:00
|
|
|
def cleanup(self) -> None:
|
|
|
|
return 0
|
|
|
|
|
2020-08-04 22:25:02 +00:00
|
|
|
def execute_wrapper(self) -> None:
|
|
|
|
with database.DB.connection_context():
|
2021-02-08 22:16:52 +00:00
|
|
|
self.execute()
|
|
|
|
|
|
|
|
def cleanup_wrapper(self) -> None:
|
|
|
|
with database.DB.connection_context():
|
|
|
|
return self.cleanup()
|