mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
remove CHECKS feature, not needed
This commit is contained in:
parent
de7ab65f11
commit
04d2316800
8 changed files with 9 additions and 114 deletions
|
@ -1,44 +0,0 @@
|
|||
__package__ = "abx.archivebox"
|
||||
|
||||
from typing import List
|
||||
|
||||
from django.core.checks import Warning, Tags, register
|
||||
|
||||
import abx
|
||||
|
||||
from .base_hook import BaseHook, HookType
|
||||
|
||||
|
||||
class BaseCheck(BaseHook):
|
||||
hook_type: HookType = "CHECK"
|
||||
|
||||
tag: str = Tags.database
|
||||
|
||||
@staticmethod
|
||||
def check(settings, logger) -> List[Warning]:
|
||||
"""Override this method to implement your custom runtime check."""
|
||||
errors = []
|
||||
# if not hasattr(settings, 'SOME_KEY'):
|
||||
# errors.extend(Error(
|
||||
# 'Missing settings.SOME_KEY after django_setup(), did SOME_KEY get loaded?',
|
||||
# id='core.C001',
|
||||
# hint='Make sure to run django_setup() is able to load settings.SOME_KEY.',
|
||||
# ))
|
||||
# logger.debug('[√] Loaded settings.PLUGINS succesfully.')
|
||||
return errors
|
||||
|
||||
@abx.hookimpl
|
||||
def get_CHECKS(self):
|
||||
return [self]
|
||||
|
||||
@abx.hookimpl
|
||||
def register_checks(self):
|
||||
"""Tell django that this check exists so it can be run automatically by django."""
|
||||
def run_check(**kwargs):
|
||||
from django.conf import settings
|
||||
import logging
|
||||
return self.check(settings, logging.getLogger("checks"))
|
||||
|
||||
run_check.__name__ = self.id
|
||||
run_check.tags = [self.tag]
|
||||
register(self.tag)(run_check)
|
|
@ -17,10 +17,6 @@ def get_EXTRACTORS():
|
|||
def get_REPLAYERS():
|
||||
return {}
|
||||
|
||||
@hookspec
|
||||
def get_CHECKS():
|
||||
return {}
|
||||
|
||||
@hookspec
|
||||
def get_ADMINDATAVIEWS():
|
||||
return {}
|
||||
|
|
|
@ -13,7 +13,6 @@ if TYPE_CHECKING:
|
|||
from .base_binary import BaseBinary, BaseBinProvider
|
||||
from .base_extractor import BaseExtractor
|
||||
from .base_replayer import BaseReplayer
|
||||
from .base_check import BaseCheck
|
||||
from .base_queue import BaseQueue
|
||||
from .base_admindataview import BaseAdminDataView
|
||||
from .base_searchbackend import BaseSearchBackend
|
||||
|
@ -79,13 +78,6 @@ def get_REPLAYERS() -> Dict[str, 'BaseReplayer']:
|
|||
for replayer in plugin_replayers
|
||||
})
|
||||
|
||||
def get_CHECKS() -> Dict[str, 'BaseCheck']:
|
||||
return benedict({
|
||||
check.id: check
|
||||
for plugin_checks in pm.hook.get_CHECKS()
|
||||
for check in plugin_checks
|
||||
})
|
||||
|
||||
def get_ADMINDATAVIEWS() -> Dict[str, 'BaseAdminDataView']:
|
||||
return benedict({
|
||||
admin_dataview.id: admin_dataview
|
||||
|
|
|
@ -62,7 +62,6 @@ BINPROVIDERS = abx.archivebox.use.get_BINPROVIDERS()
|
|||
BINARIES = abx.archivebox.use.get_BINARIES()
|
||||
EXTRACTORS = abx.archivebox.use.get_EXTRACTORS()
|
||||
REPLAYERS = abx.archivebox.use.get_REPLAYERS()
|
||||
CHECKS = abx.archivebox.use.get_CHECKS()
|
||||
ADMINDATAVIEWS = abx.archivebox.use.get_ADMINDATAVIEWS()
|
||||
QUEUES = abx.archivebox.use.get_QUEUES()
|
||||
SEARCHBACKENDS = abx.archivebox.use.get_SEARCHBACKENDS()
|
||||
|
|
|
@ -12,13 +12,12 @@ import django
|
|||
import django.db.backends.sqlite3.base
|
||||
from django.db.backends.sqlite3.base import Database as django_sqlite3 # type: ignore[import-type]
|
||||
from django.core.checks import Error, Tags
|
||||
from pydantic_pkgr import BinProvider, PipProvider, BinName, BinProviderName, ProviderLookupDict, SemVer, bin_abspath
|
||||
from pydantic_pkgr import BinProvider, PipProvider, BinName, BinProviderName, ProviderLookupDict, SemVer
|
||||
|
||||
from archivebox.config import CONSTANTS, VERSION
|
||||
|
||||
from abx.archivebox.base_plugin import BasePlugin
|
||||
from abx.archivebox.base_configset import BaseConfigSet
|
||||
from abx.archivebox.base_check import BaseCheck
|
||||
from abx.archivebox.base_binary import BaseBinary, BaseBinProvider, env, apt, brew
|
||||
from abx.archivebox.base_hook import BaseHook
|
||||
|
||||
|
@ -241,51 +240,6 @@ class PipxBinary(BaseBinary):
|
|||
PIPX_BINARY = PipxBinary()
|
||||
|
||||
|
||||
class CheckUserIsNotRoot(BaseCheck):
|
||||
label: str = 'CheckUserIsNotRoot'
|
||||
tag: str = Tags.database
|
||||
|
||||
@staticmethod
|
||||
def check(settings, logger) -> List[Warning]:
|
||||
errors = []
|
||||
if getattr(settings, "USER", None) == 'root' or getattr(settings, "PUID", None) == 0:
|
||||
errors.append(
|
||||
Error(
|
||||
"Cannot run as root!",
|
||||
id="core.S001",
|
||||
hint=f'Run ArchiveBox as a non-root user with a UID greater than 500. (currently running as UID {os.getuid()}).',
|
||||
)
|
||||
)
|
||||
# logger.debug('[√] UID is not root')
|
||||
return errors
|
||||
|
||||
|
||||
class CheckPipEnvironment(BaseCheck):
|
||||
label: str = "CheckPipEnvironment"
|
||||
tag: str = Tags.database
|
||||
|
||||
@staticmethod
|
||||
def check(settings, logger) -> List[Warning]:
|
||||
# soft errors: check that lib/pip virtualenv is setup properly
|
||||
errors = []
|
||||
|
||||
LIB_PIP_BINPROVIDER.setup()
|
||||
if not LIB_PIP_BINPROVIDER.is_valid:
|
||||
errors.append(
|
||||
Error(
|
||||
f"Failed to setup {LIB_PIP_BINPROVIDER.pip_venv} virtualenv for runtime dependencies!",
|
||||
id="pip.P001",
|
||||
hint="Make sure the data dir is writable and make sure python3-pip and python3-venv are installed & available on the host.",
|
||||
)
|
||||
)
|
||||
# logger.debug("[√] CheckPipEnvironment: data/lib/pip virtualenv is setup properly")
|
||||
return errors
|
||||
|
||||
|
||||
USER_IS_NOT_ROOT_CHECK = CheckUserIsNotRoot()
|
||||
PIP_ENVIRONMENT_CHECK = CheckPipEnvironment()
|
||||
|
||||
|
||||
class PipPlugin(BasePlugin):
|
||||
app_label: str = 'pip'
|
||||
verbose_name: str = 'PIP'
|
||||
|
@ -302,8 +256,6 @@ class PipPlugin(BasePlugin):
|
|||
PYTHON_BINARY,
|
||||
SQLITE_BINARY,
|
||||
DJANGO_BINARY,
|
||||
USER_IS_NOT_ROOT_CHECK,
|
||||
PIP_ENVIRONMENT_CHECK,
|
||||
]
|
||||
|
||||
|
||||
|
|
2
archivebox/vendor/pydantic-pkgr
vendored
2
archivebox/vendor/pydantic-pkgr
vendored
|
@ -1 +1 @@
|
|||
Subproject commit e2f6b10550f41e64817908eef3feb0aa33071969
|
||||
Subproject commit 8177447eb0d1bc93a886db1386cdfbee25343162
|
Loading…
Add table
Add a link
Reference in a new issue