feat: Patch setup_django so we can use an inmemory db in specific commands

This commit is contained in:
Cristian 2020-12-08 18:05:37 -05:00 committed by Cristian Vargas
parent 35a5700c73
commit 9aac09a5e1
6 changed files with 18 additions and 13 deletions

View file

@ -19,6 +19,8 @@ meta_cmds = ('help', 'version')
main_cmds = ('init', 'info', 'config')
archive_cmds = ('add', 'remove', 'update', 'list', 'status')
fake_db = ("oneshot",) + meta_cmds
display_first = (*meta_cmds, *main_cmds, *archive_cmds)
# every imported command module must have these properties in order to be valid
@ -59,7 +61,7 @@ def run_subcommand(subcommand: str,
pwd: Union[Path, str, None]=None) -> None:
"""Run a given ArchiveBox subcommand with the given list of args"""
from ..config import setup_django
setup_django()
setup_django(in_memory_db=subcommand in fake_db)
module = import_module('.archivebox_{}'.format(subcommand), __package__)
module.main(args=subcommand_args, stdin=stdin, pwd=pwd) # type: ignore