Skip to content

Commit 37a647d

Browse files
committed
[cli][app] Add --ignore-user-config flag #240
1 parent 1e5fe51 commit 37a647d

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

docs/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55

66
#### Changelog
77

8+
### 1.8.1 (August 27, 2025)
9+
10+
#### Release Notes
11+
12+
Fixes issue with application not loading config files saved with v1.8.
13+
14+
#### Changelog
15+
16+
* [general] Add `--ignore-user-config` flag to both `dvr-scan` and `dvr-scan-app` commands to allow the application to run even if the user config file is corrupted
17+
818

919
### 1.8 (August 23, 2025)
1020

dvr_scan/app/__main__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ def get_cli_parser():
9292
version=get_license_info(),
9393
)
9494

95+
parser.add_argument(
96+
"--ignore-user-config",
97+
action="store_true",
98+
default=False,
99+
help=("Ignore loading the user config file if present."),
100+
)
101+
95102
parser.add_argument(
96103
"--debug",
97104
action="store_true",
@@ -130,6 +137,9 @@ def main():
130137
# Parse CLI args, override config if an override was specified on the command line.
131138
try:
132139
args = get_cli_parser().parse_args()
140+
if args.ignore_user_config:
141+
config_load_error = None
142+
user_config = ConfigRegistry()
133143
init_logging(args, config)
134144
init_log += [(logging.INFO, "DVR-Scan Application %s" % dvr_scan.__version__)]
135145
if config_load_error and not hasattr(args, "config"):

dvr_scan/cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,13 @@ def get_cli_parser(user_config: ConfigRegistry):
492492
help=("Use OpenCV provided presentation timestamp instead of calculated version."),
493493
)
494494

495+
parser.add_argument(
496+
"--ignore-user-config",
497+
action="store_true",
498+
default=False,
499+
help=("Ignore loading the user config file if present."),
500+
)
501+
495502
parser.add_argument(
496503
"--debug",
497504
action="store_true",

dvr_scan/controller.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ def parse_settings() -> ty.Optional[ScanSettings]:
8686
# Parse CLI args, override config if an override was specified on the command line.
8787
try:
8888
args = get_cli_parser(config).parse_args()
89+
if args.ignore_user_config:
90+
config_load_error = None
91+
user_config = ConfigRegistry()
8992
debug_mode = args.debug
9093
init_logging(args=args, config=config)
9194
init_log += [(logging.INFO, "DVR-Scan %s" % dvr_scan.__version__)]

tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"0",
4343
"--threshold",
4444
"0.2",
45+
"--ignore-user-config"
4546
]
4647
BASE_COMMAND_NUM_EVENTS = 3
4748

0 commit comments

Comments
 (0)