hide errors if user is just getting help or version info

This commit is contained in:
Nick Sweeting 2024-10-08 19:20:03 -07:00
parent 9f274cf9f4
commit 7c34f2bc90
No known key found for this signature in database
2 changed files with 15 additions and 11 deletions

View file

@ -595,16 +595,20 @@ def setup_django(out_dir: Path | None=None, check_db=False, config: benedict=CON
django.setup() django.setup()
except Exception as e: except Exception as e:
bump_startup_progress_bar(advance=1000) bump_startup_progress_bar(advance=1000)
STDERR.print()
STDERR.print(Panel( subcommand = sys.argv[1] if len(sys.argv) > 1 else 'unknown'
f'\n[red]{e.__class__.__name__}[/red]: [yellow]{e}[/yellow]\nPlease check your config and [blue]DATA_DIR[/blue] permissions.\n', if subcommand not in ('help', 'version', '--help', '--version'):
title='\n\n[red][X] Error while trying to load database![/red]', # show error message to user only if they're not running a meta command / just trying to get help
subtitle='[grey53]NO WRITES CAN BE PERFORMED[/grey53]', STDERR.print()
expand=False, STDERR.print(Panel(
style='bold red', f'\n[red]{e.__class__.__name__}[/red]: [yellow]{e}[/yellow]\nPlease check your config and [blue]DATA_DIR[/blue] permissions.\n',
)) title='\n\n[red][X] Error while trying to load database![/red]',
STDERR.print() subtitle='[grey53]NO WRITES CAN BE PERFORMED[/grey53]',
STDERR.print_exception(show_locals=False) expand=False,
style='bold red',
))
STDERR.print()
STDERR.print_exception(show_locals=False)
return return
bump_startup_progress_bar() bump_startup_progress_bar()

View file

@ -1,6 +1,6 @@
[project] [project]
name = "archivebox" name = "archivebox"
version = "0.8.5rc19" version = "0.8.5rc20"
requires-python = ">=3.10" requires-python = ">=3.10"
description = "Self-hosted internet archiving solution." description = "Self-hosted internet archiving solution."
authors = [{name = "Nick Sweeting", email = "pyproject.toml@archivebox.io"}] authors = [{name = "Nick Sweeting", email = "pyproject.toml@archivebox.io"}]