mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
speed up version command by checking if quiet is passed
This commit is contained in:
parent
31ce490321
commit
51fe4c38c2
2 changed files with 88 additions and 80 deletions
|
@ -8,17 +8,17 @@ import argparse
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional, List, IO
|
from typing import Optional, List, IO
|
||||||
|
|
||||||
from archivebox.misc.util import docstring
|
# from archivebox.misc.util import docstring
|
||||||
from archivebox.config import DATA_DIR
|
from archivebox.config import DATA_DIR, VERSION
|
||||||
from ..logging_util import SmartFormatter, reject_stdin
|
from ..logging_util import SmartFormatter, reject_stdin
|
||||||
from ..main import version
|
|
||||||
|
|
||||||
|
|
||||||
@docstring(version.__doc__)
|
# @docstring(version.__doc__)
|
||||||
def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional[str]=None) -> None:
|
def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional[str]=None) -> None:
|
||||||
|
"""Print the ArchiveBox version and dependency information"""
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
prog=__command__,
|
prog=__command__,
|
||||||
description=version.__doc__,
|
description="Print the ArchiveBox version and dependency information", # version.__doc__,
|
||||||
add_help=True,
|
add_help=True,
|
||||||
formatter_class=SmartFormatter,
|
formatter_class=SmartFormatter,
|
||||||
)
|
)
|
||||||
|
@ -30,6 +30,13 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
|
||||||
command = parser.parse_args(args or ())
|
command = parser.parse_args(args or ())
|
||||||
reject_stdin(__command__, stdin)
|
reject_stdin(__command__, stdin)
|
||||||
|
|
||||||
|
# for speed reasons, check if quiet flag was set and just return simple version immediately if so
|
||||||
|
if command.quiet:
|
||||||
|
print(VERSION)
|
||||||
|
return
|
||||||
|
|
||||||
|
# otherwise do big expensive import to get the full version
|
||||||
|
from ..main import version
|
||||||
version(
|
version(
|
||||||
quiet=command.quiet,
|
quiet=command.quiet,
|
||||||
out_dir=Path(pwd) if pwd else DATA_DIR,
|
out_dir=Path(pwd) if pwd else DATA_DIR,
|
||||||
|
|
|
@ -169,89 +169,90 @@ def version(quiet: bool=False,
|
||||||
"""Print the ArchiveBox version and dependency information"""
|
"""Print the ArchiveBox version and dependency information"""
|
||||||
|
|
||||||
from rich import print
|
from rich import print
|
||||||
|
print(VERSION)
|
||||||
|
if quiet:
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
from plugins_auth.ldap.apps import LDAP_CONFIG
|
from plugins_auth.ldap.apps import LDAP_CONFIG
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
print(VERSION)
|
# 0.7.1
|
||||||
|
# ArchiveBox v0.7.1+editable COMMIT_HASH=951bba5 BUILD_TIME=2023-12-17 16:46:05 1702860365
|
||||||
|
# IN_DOCKER=False IN_QEMU=False ARCH=arm64 OS=Darwin PLATFORM=macOS-14.2-arm64-arm-64bit PYTHON=Cpython
|
||||||
|
# FS_ATOMIC=True FS_REMOTE=False FS_USER=501:20 FS_PERMS=644
|
||||||
|
# DEBUG=False IS_TTY=True TZ=UTC SEARCH_BACKEND=ripgrep LDAP=False
|
||||||
|
|
||||||
if not quiet:
|
p = platform.uname()
|
||||||
# 0.7.1
|
print(
|
||||||
# ArchiveBox v0.7.1+editable COMMIT_HASH=951bba5 BUILD_TIME=2023-12-17 16:46:05 1702860365
|
'ArchiveBox v{}'.format(CONSTANTS.VERSION),
|
||||||
# IN_DOCKER=False IN_QEMU=False ARCH=arm64 OS=Darwin PLATFORM=macOS-14.2-arm64-arm-64bit PYTHON=Cpython
|
f'COMMIT_HASH={SHELL_CONFIG.COMMIT_HASH[:7] if SHELL_CONFIG.COMMIT_HASH else "unknown"}',
|
||||||
# FS_ATOMIC=True FS_REMOTE=False FS_USER=501:20 FS_PERMS=644
|
f'BUILD_TIME={SHELL_CONFIG.BUILD_TIME}',
|
||||||
# DEBUG=False IS_TTY=True TZ=UTC SEARCH_BACKEND=ripgrep LDAP=False
|
)
|
||||||
|
print(
|
||||||
|
f'IN_DOCKER={SHELL_CONFIG.IN_DOCKER}',
|
||||||
|
f'IN_QEMU={SHELL_CONFIG.IN_QEMU}',
|
||||||
|
f'ARCH={p.machine}',
|
||||||
|
f'OS={p.system}',
|
||||||
|
f'PLATFORM={platform.platform()}',
|
||||||
|
f'PYTHON={sys.implementation.name.title()}',
|
||||||
|
)
|
||||||
|
OUTPUT_IS_REMOTE_FS = CONSTANTS.DATA_LOCATIONS.DATA_DIR.is_mount or CONSTANTS.DATA_LOCATIONS.ARCHIVE_DIR.is_mount
|
||||||
|
print(
|
||||||
|
f'FS_ATOMIC={STORAGE_CONFIG.ENFORCE_ATOMIC_WRITES}',
|
||||||
|
f'FS_REMOTE={OUTPUT_IS_REMOTE_FS}',
|
||||||
|
f'FS_USER={SHELL_CONFIG.PUID}:{SHELL_CONFIG.PGID}',
|
||||||
|
f'FS_PERMS={STORAGE_CONFIG.OUTPUT_PERMISSIONS}',
|
||||||
|
)
|
||||||
|
print(
|
||||||
|
f'DEBUG={SHELL_CONFIG.DEBUG}',
|
||||||
|
f'IS_TTY={SHELL_CONFIG.IS_TTY}',
|
||||||
|
f'TZ={CONSTANTS.TIMEZONE}',
|
||||||
|
f'SEARCH_BACKEND={SEARCH_BACKEND_CONFIG.SEARCH_BACKEND_ENGINE}',
|
||||||
|
f'LDAP={LDAP_CONFIG.LDAP_ENABLED}',
|
||||||
|
#f'DB=django.db.backends.sqlite3 (({CONFIG["SQLITE_JOURNAL_MODE"]})', # add this if we have more useful info to show eventually
|
||||||
|
)
|
||||||
|
print()
|
||||||
|
|
||||||
p = platform.uname()
|
print('[pale_green3][i] Old dependency versions:[/pale_green3]')
|
||||||
print(
|
for name, dependency in DEPENDENCIES.items():
|
||||||
'ArchiveBox v{}'.format(CONSTANTS.VERSION),
|
print(printable_dependency_version(name, dependency))
|
||||||
f'COMMIT_HASH={SHELL_CONFIG.COMMIT_HASH[:7] if SHELL_CONFIG.COMMIT_HASH else "unknown"}',
|
|
||||||
f'BUILD_TIME={SHELL_CONFIG.BUILD_TIME}',
|
|
||||||
)
|
|
||||||
print(
|
|
||||||
f'IN_DOCKER={SHELL_CONFIG.IN_DOCKER}',
|
|
||||||
f'IN_QEMU={SHELL_CONFIG.IN_QEMU}',
|
|
||||||
f'ARCH={p.machine}',
|
|
||||||
f'OS={p.system}',
|
|
||||||
f'PLATFORM={platform.platform()}',
|
|
||||||
f'PYTHON={sys.implementation.name.title()}',
|
|
||||||
)
|
|
||||||
OUTPUT_IS_REMOTE_FS = CONSTANTS.DATA_LOCATIONS.DATA_DIR.is_mount or CONSTANTS.DATA_LOCATIONS.ARCHIVE_DIR.is_mount
|
|
||||||
print(
|
|
||||||
f'FS_ATOMIC={STORAGE_CONFIG.ENFORCE_ATOMIC_WRITES}',
|
|
||||||
f'FS_REMOTE={OUTPUT_IS_REMOTE_FS}',
|
|
||||||
f'FS_USER={SHELL_CONFIG.PUID}:{SHELL_CONFIG.PGID}',
|
|
||||||
f'FS_PERMS={STORAGE_CONFIG.OUTPUT_PERMISSIONS}',
|
|
||||||
)
|
|
||||||
print(
|
|
||||||
f'DEBUG={SHELL_CONFIG.DEBUG}',
|
|
||||||
f'IS_TTY={SHELL_CONFIG.IS_TTY}',
|
|
||||||
f'TZ={CONSTANTS.TIMEZONE}',
|
|
||||||
f'SEARCH_BACKEND={SEARCH_BACKEND_CONFIG.SEARCH_BACKEND_ENGINE}',
|
|
||||||
f'LDAP={LDAP_CONFIG.LDAP_ENABLED}',
|
|
||||||
#f'DB=django.db.backends.sqlite3 (({CONFIG["SQLITE_JOURNAL_MODE"]})', # add this if we have more useful info to show eventually
|
|
||||||
)
|
|
||||||
print()
|
|
||||||
|
|
||||||
print('[pale_green3][i] Old dependency versions:[/pale_green3]')
|
# add a newline between core dependencies and extractor dependencies for easier reading
|
||||||
for name, dependency in DEPENDENCIES.items():
|
if name == 'ARCHIVEBOX_BINARY':
|
||||||
print(printable_dependency_version(name, dependency))
|
|
||||||
|
|
||||||
# add a newline between core dependencies and extractor dependencies for easier reading
|
|
||||||
if name == 'ARCHIVEBOX_BINARY':
|
|
||||||
print()
|
|
||||||
|
|
||||||
print()
|
|
||||||
print('[pale_green1][i] New dependency versions:[/pale_green1]')
|
|
||||||
for name, binary in reversed(list(settings.BINARIES.items())):
|
|
||||||
if binary.name == 'archivebox':
|
|
||||||
continue
|
|
||||||
|
|
||||||
err = None
|
|
||||||
try:
|
|
||||||
loaded_bin = binary.load()
|
|
||||||
except Exception as e:
|
|
||||||
err = e
|
|
||||||
loaded_bin = binary
|
|
||||||
raise
|
|
||||||
provider_summary = f'[dark_sea_green3]{loaded_bin.binprovider.name.ljust(10)}[/dark_sea_green3]' if loaded_bin.binprovider else '[grey23]not found[/grey23]'
|
|
||||||
print('', '[green]√[/green]' if loaded_bin.is_valid else '[red]X[/red]', '', loaded_bin.name.ljust(21), str(loaded_bin.version).ljust(12), provider_summary, loaded_bin.abspath or f'[red]{err}[/red]')
|
|
||||||
|
|
||||||
print()
|
|
||||||
print('[white][i] Source-code locations:[/white]')
|
|
||||||
for name, path in CONSTANTS.CODE_LOCATIONS.items():
|
|
||||||
print(printable_folder_status(name, path))
|
|
||||||
|
|
||||||
print()
|
|
||||||
if CONSTANTS.DATABASE_FILE.exists() or CONSTANTS.ARCHIVE_DIR.exists() or CONSTANTS.CONFIG_FILE.exists():
|
|
||||||
print('[white][i] Data locations:[/]')
|
|
||||||
for name, path in CONSTANTS.DATA_LOCATIONS.items():
|
|
||||||
print(printable_folder_status(name, path))
|
|
||||||
else:
|
|
||||||
print()
|
print()
|
||||||
print('[white][i] Data locations:[/white] (not in a data directory)')
|
|
||||||
|
|
||||||
|
print()
|
||||||
|
print('[pale_green1][i] New dependency versions:[/pale_green1]')
|
||||||
|
for name, binary in reversed(list(settings.BINARIES.items())):
|
||||||
|
if binary.name == 'archivebox':
|
||||||
|
continue
|
||||||
|
|
||||||
|
err = None
|
||||||
|
try:
|
||||||
|
loaded_bin = binary.load()
|
||||||
|
except Exception as e:
|
||||||
|
err = e
|
||||||
|
loaded_bin = binary
|
||||||
|
raise
|
||||||
|
provider_summary = f'[dark_sea_green3]{loaded_bin.binprovider.name.ljust(10)}[/dark_sea_green3]' if loaded_bin.binprovider else '[grey23]not found[/grey23]'
|
||||||
|
print('', '[green]√[/green]' if loaded_bin.is_valid else '[red]X[/red]', '', loaded_bin.name.ljust(21), str(loaded_bin.version).ljust(12), provider_summary, loaded_bin.abspath or f'[red]{err}[/red]')
|
||||||
|
|
||||||
|
print()
|
||||||
|
print('[white][i] Source-code locations:[/white]')
|
||||||
|
for name, path in CONSTANTS.CODE_LOCATIONS.items():
|
||||||
|
print(printable_folder_status(name, path))
|
||||||
|
|
||||||
|
print()
|
||||||
|
if CONSTANTS.DATABASE_FILE.exists() or CONSTANTS.ARCHIVE_DIR.exists() or CONSTANTS.CONFIG_FILE.exists():
|
||||||
|
print('[white][i] Data locations:[/]')
|
||||||
|
for name, path in CONSTANTS.DATA_LOCATIONS.items():
|
||||||
|
print(printable_folder_status(name, path))
|
||||||
|
else:
|
||||||
print()
|
print()
|
||||||
|
print('[white][i] Data locations:[/white] (not in a data directory)')
|
||||||
|
|
||||||
|
print()
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue