| 561 | |
| 562 | |
| 563 | def validate_file_permissions(args: argparse.Namespace) -> None: |
| 564 | error_string_template = ( |
| 565 | "unable to {action} {file}; " |
| 566 | "try ensuring file exists and has correct permissions" |
| 567 | ) |
| 568 | if ( |
| 569 | args.reference is not None |
| 570 | and not is_remote_url(args.reference) # ffmpeg streams URLs directly; no local file to check |
| 571 | and not os.access(args.reference, os.R_OK) |
| 572 | ): |
| 573 | raise ValueError( |
| 574 | error_string_template.format(action="read reference", file=args.reference) |
| 575 | ) |
| 576 | if args.srtin: |
| 577 | for srtin in args.srtin: |
| 578 | if srtin is not None and not os.access(srtin, os.R_OK): |
| 579 | raise ValueError( |
| 580 | error_string_template.format( |
| 581 | action="read input subtitles", file=srtin |
| 582 | ) |
| 583 | ) |
| 584 | if ( |
| 585 | args.srtout is not None |
| 586 | and os.path.exists(args.srtout) |
| 587 | and not os.access(args.srtout, os.W_OK) |
| 588 | ): |
| 589 | raise ValueError( |
| 590 | error_string_template.format( |
| 591 | action="write output subtitles", file=args.srtout |
| 592 | ) |
| 593 | ) |
| 594 | if args.make_test_case or args.serialize_speech: |
| 595 | npy_savename = os.path.splitext(args.reference)[0] + ".npz" |
| 596 | if os.path.exists(npy_savename) and not os.access(npy_savename, os.W_OK): |
| 597 | raise ValueError( |
| 598 | "unable to write test case file archive %s (try checking permissions)" |
| 599 | % npy_savename |
| 600 | ) |
| 601 | |
| 602 | |
| 603 | def _setup_logging( |