MCPcopy
hub / github.com/ArchiveBox/ArchiveBox / run_subcommand

Function run_subcommand

archivebox/cli/__init__.py:57–80  ·  view source on GitHub ↗

Run a given ArchiveBox subcommand with the given list of args

(subcommand: str,
                   subcommand_args: List[str]=None,
                   stdin: Optional[IO]=None,
                   pwd: Union[Path, str, None]=None)

Source from the content-addressed store, hash-verified

55
56
57def run_subcommand(subcommand: str,
58 subcommand_args: List[str]=None,
59 stdin: Optional[IO]=None,
60 pwd: Union[Path, str, None]=None) -> None:
61 """Run a given ArchiveBox subcommand with the given list of args"""
62
63 subcommand_args = subcommand_args or []
64
65 if subcommand not in meta_cmds:
66 from ..config import setup_django
67
68 cmd_requires_db = subcommand in archive_cmds
69 init_pending = '--init' in subcommand_args or '--quick-init' in subcommand_args
70
71 if cmd_requires_db:
72 check_data_folder(pwd)
73
74 setup_django(in_memory_db=subcommand in fake_db, check_db=cmd_requires_db and not init_pending)
75
76 if cmd_requires_db:
77 check_migrations()
78
79 module = import_module('.archivebox_{}'.format(subcommand), __package__)
80 module.main(args=subcommand_args, stdin=stdin, pwd=pwd) # type: ignore
81
82
83SUBCOMMANDS = list_subcommands()

Callers 7

runFunction · 0.85
initFunction · 0.85
addFunction · 0.85
setupFunction · 0.85
serverFunction · 0.85
handleMethod · 0.85
mainFunction · 0.85

Calls 3

check_data_folderFunction · 0.85
setup_djangoFunction · 0.85
check_migrationsFunction · 0.85

Tested by

no test coverage detected