mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-25 21:50:21 +00:00
add pudb and type hints
This commit is contained in:
parent
17213eaebf
commit
308b493469
6 changed files with 26 additions and 23 deletions
|
@ -87,25 +87,25 @@ class ArchiveBoxBaseDependency(models.Model):
|
|||
}
|
||||
|
||||
@cached_property
|
||||
def bin_path(self):
|
||||
def bin_path(self) -> str:
|
||||
return bin_path(self.BINARY or self.DEFAULT_BINARY)
|
||||
|
||||
@cached_property
|
||||
def bin_version(self):
|
||||
def bin_version(self) -> str | None:
|
||||
print(f'ArchiveBoxBaseDependency.bin_version({self.bin_path}, cmd={self.VERSION_CMD.format(BINARY=self.BINARY)})')
|
||||
return bin_version(self.bin_path, cmd=self.VERSION_CMD.format(BINARY=self.BINARY))
|
||||
# return bin_version(self.bin_path, cmd=self.VERSION_CMD)
|
||||
|
||||
@cached_property
|
||||
def is_valid(self):
|
||||
def is_valid(self) -> bool:
|
||||
return bool(self.bin_path and self.bin_version)
|
||||
|
||||
@cached_property
|
||||
def is_enabled(self):
|
||||
def is_enabled(self) -> bool:
|
||||
return bool(self.ENABLED and self.is_valid)
|
||||
|
||||
@cached_property
|
||||
def pretty_version(self):
|
||||
def pretty_version(self) -> str:
|
||||
if self.is_enabled:
|
||||
if self.is_valid:
|
||||
color, symbol, note, version = 'green', '√', 'valid', ''
|
||||
|
@ -142,7 +142,7 @@ class ArchiveBoxBaseDependency(models.Model):
|
|||
|
||||
# @helper
|
||||
def install_self(self, config):
|
||||
assert all(self.install_parents().values())
|
||||
assert all(self.install_parents(config=config).values())
|
||||
|
||||
BashEnvironmentDependency.get_solo().install_pkgs(self.BIN_DEPENDENCIES)
|
||||
AptEnvironmentDependency.get_solo().install_pkgs(self.APT_DEPENDENCIES)
|
||||
|
@ -174,7 +174,7 @@ class ArchiveBoxDefaultDependency(ArchiveBoxBaseDependency, SingletonModel):
|
|||
|
||||
ENABLED = models.BooleanField(default=True, editable=True)
|
||||
|
||||
class Meta:
|
||||
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
||||
abstract = False
|
||||
app_label = 'defaults'
|
||||
verbose_name = 'Default Configuration: Dependencies'
|
||||
|
@ -212,9 +212,9 @@ class ArchiveBoxBaseExtractor(models.Model):
|
|||
def __str__(self):
|
||||
return f"{self.LABEL} Extractor Configuration"
|
||||
|
||||
class Meta:
|
||||
class Meta: # pyright: ignore [reportIncompatibleVariableOverride]
|
||||
abstract = True
|
||||
verbose_name = f"Default Extractor Configuration"
|
||||
verbose_name = "Default Extractor Configuration"
|
||||
app_label = 'defaults'
|
||||
|
||||
@cached_property
|
||||
|
|
|
@ -179,6 +179,8 @@ class AptEnvironmentDependency(ArchiveBoxBaseDependency, SingletonModel):
|
|||
def install_pkgs(self, apt_pkgs=()):
|
||||
assert self.is_valid, 'Apt environment is not available on this host'
|
||||
|
||||
# with huey.lock_task('apt-install'):
|
||||
|
||||
run(cmd=[self.DEFAULT_BINARY, '-qq', 'update'])
|
||||
for apt_package in apt_pkgs:
|
||||
run(cmd=[self.DEFAULT_BINARY, 'install', '-y', apt_package])
|
||||
|
|
|
@ -64,7 +64,7 @@ if [[ -d "$DATA_DIR/archive" ]]; then
|
|||
rm -f "$DATA_DIR/archive/.permissions_test_safe_to_delete"
|
||||
# echo "[√] Permissions are correct"
|
||||
else
|
||||
# the only time this fails is if the host filesystem doesn't allow us to write as root (e.g. some NFS mapall/maproot problems, connection issues, drive dissapeared, etc.)
|
||||
# the only time this fails is if the host filesystem doesn't allow us to write as root (e.g. some NFS mapall/maproot problems, connection issues, drive dissapeared, etc.)
|
||||
echo -e "\n[X] Error: archivebox user (PUID=$PUID) is not able to write to your ./data/archive dir (currently owned by $(stat -c '%u' "$DATA_DIR/archive"):$(stat -c '%g' "$DATA_DIR/archive")." > /dev/stderr
|
||||
echo -e " Change ./data to be owned by PUID=$PUID PGID=$PGID on the host and retry:" > /dev/stderr
|
||||
echo -e " \$ chown -R $PUID:$PGID ./data\n" > /dev/stderr
|
||||
|
|
|
@ -9,8 +9,7 @@
|
|||
# https://github.com/ArchiveBox/ArchiveBox/wiki/Docker#docker-compose
|
||||
|
||||
---
|
||||
|
||||
version: '3.9'
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
archivebox:
|
||||
|
|
23
package.json
23
package.json
|
@ -1,13 +1,14 @@
|
|||
{
|
||||
"name": "archivebox",
|
||||
"version": "0.7.3",
|
||||
"description": "ArchiveBox: The self-hosted internet archive",
|
||||
"author": "Nick Sweeting <archivebox-npm@sweeting.me>",
|
||||
"repository": "github:ArchiveBox/ArchiveBox",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@postlight/parser": "^2.2.3",
|
||||
"readability-extractor": "github:ArchiveBox/readability-extractor",
|
||||
"single-file-cli": "^1.1.46"
|
||||
}
|
||||
"name": "archivebox",
|
||||
"version": "0.7.3",
|
||||
"description": "ArchiveBox: The self-hosted internet archive",
|
||||
"author": "Nick Sweeting <archivebox-npm@sweeting.me>",
|
||||
"repository": "github:ArchiveBox/ArchiveBox",
|
||||
"license": "MIT",
|
||||
"dependencies":
|
||||
{
|
||||
"@postlight/parser": "^2.2.3",
|
||||
"readability-extractor": "github:ArchiveBox/readability-extractor",
|
||||
"single-file-cli": "^1.1.46"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ dev = [
|
|||
"mypy",
|
||||
"django-stubs[compatible-mypy]>=4.2.7",
|
||||
"types-requests>=2.31.0.20240125",
|
||||
"pudb>=2024.1",
|
||||
]
|
||||
|
||||
[tool.pyright]
|
||||
|
|
Loading…
Reference in a new issue