mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 07:34:27 -04:00
better dependency version check
This commit is contained in:
parent
2f282402c7
commit
9d093a34f8
1 changed files with 31 additions and 30 deletions
|
@ -504,22 +504,29 @@ def bin_version(binary: Optional[str]) -> Optional[str]:
|
||||||
"""check the presence and return valid version line of a specified binary"""
|
"""check the presence and return valid version line of a specified binary"""
|
||||||
|
|
||||||
abspath = bin_path(binary)
|
abspath = bin_path(binary)
|
||||||
if not abspath:
|
if not binary or not abspath:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
version_str = run([abspath, "--version"], stdout=PIPE).stdout.strip().decode()
|
if binary.split('/')[-1] in ('single-file',):
|
||||||
# take first 3 columns of first line of version info
|
# these dependencies dont support the --version flag, but are valid still
|
||||||
return ' '.join(version_str.split('\n')[0].strip().split()[:3])
|
if run([abspath, "--help"], stdout=PIPE).returncode == 0:
|
||||||
except Exception:
|
return '0.0.0'
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
version_str = run([abspath, "--version"], stdout=PIPE).stdout.strip().decode()
|
||||||
|
# take first 3 columns of first line of version info
|
||||||
|
return ' '.join(version_str.split('\n')[0].strip().split()[:3])
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
# stderr(f'[X] Unable to find working version of dependency: {binary}', color='red')
|
# stderr(f'[X] Unable to find working version of dependency: {binary}', color='red')
|
||||||
# stderr(' Make sure it\'s installed, then confirm it\'s working by running:')
|
# stderr(' Make sure it\'s installed, then confirm it\'s working by running:')
|
||||||
# stderr(f' {binary} --version')
|
# stderr(f' {binary} --version')
|
||||||
# stderr()
|
# stderr()
|
||||||
# stderr(' If you don\'t want to install it, you can disable it via config. See here for more info:')
|
# stderr(' If you don\'t want to install it, you can disable it via config. See here for more info:')
|
||||||
# stderr(' https://github.com/pirate/ArchiveBox/wiki/Install')
|
# stderr(' https://github.com/pirate/ArchiveBox/wiki/Install')
|
||||||
# stderr()
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
def bin_path(binary: Optional[str]) -> Optional[str]:
|
def bin_path(binary: Optional[str]) -> Optional[str]:
|
||||||
if binary is None:
|
if binary is None:
|
||||||
|
@ -816,42 +823,36 @@ def check_system_config(config: ConfigDict=CONFIG) -> None:
|
||||||
stderr(' CHROME_USER_DATA_DIR="{}"'.format(config['CHROME_USER_DATA_DIR'].split('/Default')[0]))
|
stderr(' CHROME_USER_DATA_DIR="{}"'.format(config['CHROME_USER_DATA_DIR'].split('/Default')[0]))
|
||||||
raise SystemExit(2)
|
raise SystemExit(2)
|
||||||
|
|
||||||
def dependency_additional_info(dependency: str) -> str:
|
def print_dependency_additional_info(dependency: str) -> None:
|
||||||
if dependency == "SINGLEFILE_BINARY":
|
if dependency == "SINGLEFILE_BINARY":
|
||||||
return (
|
hint(('npm install -g git+https://github.com/gildas-lormeau/SingleFile.git"',
|
||||||
"npm install -g git+https://github.com/gildas-lormeau/SingleFile.git"
|
'or set SAVE_SINGLEFILE=False to silence this warning',
|
||||||
"\n and set SINGLEFILE_BINARY=$(which single-file)"
|
''))
|
||||||
"\n or set USE_SINGLEFILE=False"
|
|
||||||
)
|
|
||||||
if dependency == "READABILITY_BINARY":
|
if dependency == "READABILITY_BINARY":
|
||||||
return (
|
hint(('npm install -g git+https://github.com/pirate/readability-extractor.git"',
|
||||||
"npm install -g git+https://github.com/pirate/readability-extractor.git"
|
'or set SAVE_READABILITY=False to silence this warning',
|
||||||
"\n and set READABILITY_BINARY=$(which readability-extractor)"
|
''))
|
||||||
"\n or set USE_READABILITY=False"
|
|
||||||
)
|
|
||||||
return ""
|
|
||||||
|
|
||||||
|
|
||||||
def check_dependencies(config: ConfigDict=CONFIG, show_help: bool=True) -> None:
|
def check_dependencies(config: ConfigDict=CONFIG, show_help: bool=True) -> None:
|
||||||
invalid = [
|
invalid_dependencies = [
|
||||||
(name, info) for name, info in config['DEPENDENCIES'].items()
|
(name, info) for name, info in config['DEPENDENCIES'].items()
|
||||||
if info['enabled'] and not info['is_valid']
|
if info['enabled'] and not info['is_valid']
|
||||||
]
|
]
|
||||||
if invalid and show_help:
|
if invalid_dependencies and show_help:
|
||||||
stderr(f'[!] Warning: Missing {len(invalid)} recommended dependencies', color='lightyellow')
|
stderr(f'[!] Warning: Missing {len(invalid_dependencies)} recommended dependencies', color='lightyellow')
|
||||||
for name, info in invalid:
|
for dependency, info in invalid_dependencies:
|
||||||
stderr(
|
stderr(
|
||||||
'{}: {} ({})'.format(
|
' ! {}: {} ({})'.format(
|
||||||
name,
|
dependency,
|
||||||
info['path'] or 'unable to find binary',
|
info['path'] or 'unable to find binary',
|
||||||
info['version'] or 'unable to detect version',
|
info['version'] or 'unable to detect version',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
stderr(f' {dependency_additional_info(name)}')
|
print_dependency_additional_info(dependency)
|
||||||
stderr()
|
stderr(' {lightred}Hint:{reset} To get more info on dependencies run:'.format(**ANSI))
|
||||||
stderr('To get more info on dependencies run:')
|
stderr(' archivebox --version')
|
||||||
stderr(' archivebox --version')
|
stderr('')
|
||||||
stderr('')
|
|
||||||
|
|
||||||
if config['TIMEOUT'] < 5:
|
if config['TIMEOUT'] < 5:
|
||||||
stderr()
|
stderr()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue