mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 16:51:00 +00:00
Fixed #257: runstator exclude option
This commit is contained in:
parent
113db4ab3a
commit
d51a08ef8c
1 changed files with 13 additions and 0 deletions
|
@ -40,6 +40,13 @@ class Command(BaseCommand):
|
||||||
default=0,
|
default=0,
|
||||||
help="How long to run for before exiting (defaults to infinite)",
|
help="How long to run for before exiting (defaults to infinite)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--exclude",
|
||||||
|
"-x",
|
||||||
|
type=str,
|
||||||
|
action="append",
|
||||||
|
help="Model labels that should not be processed",
|
||||||
|
)
|
||||||
parser.add_argument("model_labels", nargs="*", type=str)
|
parser.add_argument("model_labels", nargs="*", type=str)
|
||||||
|
|
||||||
def handle(
|
def handle(
|
||||||
|
@ -49,6 +56,7 @@ class Command(BaseCommand):
|
||||||
liveness_file: str,
|
liveness_file: str,
|
||||||
schedule_interval: int,
|
schedule_interval: int,
|
||||||
run_for: int,
|
run_for: int,
|
||||||
|
exclude: list[str],
|
||||||
*args,
|
*args,
|
||||||
**options
|
**options
|
||||||
):
|
):
|
||||||
|
@ -59,8 +67,13 @@ class Command(BaseCommand):
|
||||||
list[type[StatorModel]],
|
list[type[StatorModel]],
|
||||||
[apps.get_model(label) for label in model_labels],
|
[apps.get_model(label) for label in model_labels],
|
||||||
)
|
)
|
||||||
|
excluded = cast(
|
||||||
|
list[type[StatorModel]],
|
||||||
|
[apps.get_model(label) for label in (exclude or [])],
|
||||||
|
)
|
||||||
if not models:
|
if not models:
|
||||||
models = StatorModel.subclasses
|
models = StatorModel.subclasses
|
||||||
|
models = [model for model in models if model not in excluded]
|
||||||
print("Running for models: " + " ".join(m._meta.label_lower for m in models))
|
print("Running for models: " + " ".join(m._meta.label_lower for m in models))
|
||||||
# Run a runner
|
# Run a runner
|
||||||
runner = StatorRunner(
|
runner = StatorRunner(
|
||||||
|
|
Loading…
Reference in a new issue