run: add CLI option to skip external sources

makes testing faster in some cases
This commit is contained in:
Christoph Reiter 2024-06-30 15:45:09 +02:00
parent f0d1065951
commit 99a86f1ca4
3 changed files with 17 additions and 5 deletions

View File

@ -53,3 +53,4 @@ UPDATE_MIN_RATE = 1
REQUEST_TIMEOUT = 60
CACHE_DIR: str | None = None
NO_EXTERN = False

View File

@ -9,6 +9,7 @@ from asyncio import Event
from aiolimiter import AsyncLimiter
from .. import appconfig
from ..appconfig import UPDATE_INTERVAL, UPDATE_MIN_INTERVAL, UPDATE_MIN_RATE
from ..appstate import state
from ..utils import logger
@ -57,15 +58,19 @@ async def update_loop() -> None:
async with _rate_limit:
logger.info("check for updates")
try:
awaitables = [
update_cygwin_versions(),
update_gentoo_versions(),
update_arch_versions(),
awaitables = []
if not appconfig.NO_EXTERN:
awaitables.extend([
update_cygwin_versions(),
update_gentoo_versions(),
update_arch_versions(),
])
awaitables.extend([
update_source(),
update_sourceinfos(),
update_build_status(),
update_cdx(),
]
])
await asyncio.gather(*awaitables)
state.ready = True
logger.info("done")

6
run.py
View File

@ -15,6 +15,8 @@ def main(argv: list[str]) -> int | str | None:
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--cache", action="store_true",
help="use local repo cache")
parser.add_argument("-n", "--no-extern", action="store_true",
help="only use MSYS2 data, no external repos")
parser.add_argument("-p", "--port", type=int, default=8160,
help="port number")
args = parser.parse_args()
@ -25,6 +27,10 @@ def main(argv: list[str]) -> int | str | None:
logger.info(f"Using cache: {repr(cache_dir)}")
appconfig.CACHE_DIR = cache_dir
if args.no_extern:
logger.info("Not using external repos")
appconfig.NO_EXTERN = True
uvicorn.run(app, host="127.0.0.1", port=args.port, log_config=None)
return None