1
0
Fork 0
mirror of synced 2024-07-03 05:20:52 +12:00

add type hints to plugin config models

This commit is contained in:
Nick Sweeting 2024-02-08 05:55:02 -08:00
parent 97b185987d
commit 777694eb1a
4 changed files with 36 additions and 31 deletions

View file

@ -42,20 +42,20 @@ class ArchiveBoxBaseDependency(models.Model):
LABEL = "Default" LABEL = "Default"
REQUIRED = False REQUIRED = False
PARENT_DEPENDENCIES = [] PARENT_DEPENDENCIES: List[str] = []
BIN_DEPENDENCIES = [] BIN_DEPENDENCIES: List[str] = []
APT_DEPENDENCIES = [] APT_DEPENDENCIES: List[str] = []
BREW_DEPENDENCIES = [] BREW_DEPENDENCIES: List[str] = []
PIP_DEPENDENCIES = [] PIP_DEPENDENCIES: List[str] = []
NPM_DEPENDENCIES = [] NPM_DEPENDENCIES: List[str] = []
DEFAULT_BINARY = '/bin/bash' DEFAULT_BINARY: str | None = '/bin/bash'
DEFAULT_START_CMD = '/bin/bash -c "while true; do sleep 1; done"' DEFAULT_START_CMD: str | None = '/bin/bash -c "while true; do sleep 1; done"'
DEFAULT_PID_FILE = 'logs/{NAME}_WORKER.pid' DEFAULT_PID_FILE: str | None = 'logs/{NAME}_WORKER.pid'
DEFAULT_STOP_CMD = 'kill "$(<{PID_FILE})"' DEFAULT_STOP_CMD: str | None = 'kill "$(<{PID_FILE})"'
DEFAULT_VERSION_COMMAND = '{BINARY} --version' DEFAULT_VERSION_COMMAND: str | None = '{BINARY} --version'
DEFAULT_ARGS = '' DEFAULT_ARGS: str | None = ''
VERSION_CMD = '{BINARY} --version' VERSION_CMD = '{BINARY} --version'
@ -136,7 +136,8 @@ class ArchiveBoxBaseDependency(models.Model):
# @helper # @helper
def install_parents(self, config): def install_parents(self, config):
return { return {
parent_dependency.NAME: parent_dependency.get_solo().install_self() # parent_dependency.NAME: parent_dependency.get_solo().install_self()
parent_dependency: parent_dependency
for parent_dependency in self.PARENT_DEPENDENCIES for parent_dependency in self.PARENT_DEPENDENCIES
} }

View file

@ -1,8 +1,13 @@
from django.apps import AppConfig from django.apps import AppConfig
class ReplayWebPageConfig(AppConfig): class GalleryDLAppConfig(AppConfig):
label = "ReplayWeb.Page" label = "Gallery-DL"
name = "plugin_replaywebpage" name = "plugin_gallerydl"
default_auto_field = "django.db.models.BigAutoField" default_auto_field = "django.db.models.BigAutoField"
def ready(self):
# querying models is ok, but don't fetch rows from DB or perform stateful actions here
print('√ Loaded GalleryDL Plugin')

View file

@ -1,4 +1,4 @@
# __package__ = 'archivebox.plugins.system' __package__ = 'archivebox.plugins.system'
from django.apps import AppConfig from django.apps import AppConfig
@ -6,7 +6,6 @@ from django.apps import AppConfig
class SystemPluginAppConfig(AppConfig): class SystemPluginAppConfig(AppConfig):
name = "plugins.system" name = "plugins.system"
# label = "ArchiveBox System"
verbose_name = "Host System Configuration" verbose_name = "Host System Configuration"
default_auto_field = "django.db.models.AutoField" default_auto_field = "django.db.models.AutoField"

View file

@ -34,11 +34,11 @@ class BashEnvironmentDependency(ArchiveBoxBaseDependency):
PARENT_DEPENDENCIES = [] PARENT_DEPENDENCIES = []
BIN_DEPENDENCIES = ['bash'] BIN_DEPENDENCIES: List[str] = ['bash']
APT_DEPENDENCIES = [] APT_DEPENDENCIES: List[str] = []
BREW_DEPENDENCIES = [] BREW_DEPENDENCIES: List[str] = []
PIP_DEPENDENCIES = [] PIP_DEPENDENCIES: List[str] = []
NPM_DEPENDENCIES = [] NPM_DEPENDENCIES: List[str] = []
DEFAULT_BINARY = 'bash' DEFAULT_BINARY = 'bash'
DEFAULT_START_CMD = None DEFAULT_START_CMD = None
@ -152,7 +152,7 @@ class AptEnvironmentDependency(ArchiveBoxBaseDependency, SingletonModel):
LABEL = "apt" LABEL = "apt"
REQUIRED = False REQUIRED = False
PARENT_DEPENDENCIES = [BashEnvironmentDependency] PARENT_DEPENDENCIES = ['BashEnvironmentDependency']
BIN_DEPENDENCIES = ['apt-get'] BIN_DEPENDENCIES = ['apt-get']
APT_DEPENDENCIES = [] APT_DEPENDENCIES = []
@ -196,7 +196,7 @@ class BrewEnvironmentDependency(ArchiveBoxBaseDependency, SingletonModel):
LABEL = "homebrew" LABEL = "homebrew"
REQUIRED = False REQUIRED = False
PARENT_DEPENDENCIES = [BashEnvironmentDependency] PARENT_DEPENDENCIES = ['BashEnvironmentDependency']
BIN_DEPENDENCIES = ['brew'] BIN_DEPENDENCIES = ['brew']
APT_DEPENDENCIES = [] APT_DEPENDENCIES = []
@ -242,7 +242,7 @@ class PipEnvironmentDependency(ArchiveBoxBaseDependency, SingletonModel):
LABEL = "pip" LABEL = "pip"
REQUIRED = False REQUIRED = False
PARENT_DEPENDENCIES = [BashEnvironmentDependency] PARENT_DEPENDENCIES = ['BashEnvironmentDependency']
BIN_DEPENDENCIES = ['python3', 'pip3'] BIN_DEPENDENCIES = ['python3', 'pip3']
APT_DEPENDENCIES = ['python3.11', 'pip3', 'pipx'] APT_DEPENDENCIES = ['python3.11', 'pip3', 'pipx']
@ -285,7 +285,7 @@ class NPMEnvironmentDependency(ArchiveBoxBaseDependency, SingletonModel):
LABEL = "NodeJS" LABEL = "NodeJS"
REQUIRED = False REQUIRED = False
PARENT_DEPENDENCIES = [BashEnvironmentDependency] PARENT_DEPENDENCIES = ['BashEnvironmentDependency']
BIN_DEPENDENCIES = ['node', 'npm'] BIN_DEPENDENCIES = ['node', 'npm']
APT_DEPENDENCIES = ['node', 'npm'] APT_DEPENDENCIES = ['node', 'npm']
@ -412,9 +412,9 @@ class ArchiveBoxDependency(ArchiveBoxBaseDependency):
REQUIRED = True REQUIRED = True
PARENT_DEPENDENCIES = [ PARENT_DEPENDENCIES = [
PipEnvironmentDependency, 'PipEnvironmentDependency',
DjangoDependency, 'DjangoDependency',
SQLiteDependency, 'SQLiteDependency',
] ]
BIN_DEPENDENCIES = ['archivebox'] BIN_DEPENDENCIES = ['archivebox']