Same as calling Python's subprocess.call() method, but explicitly raises a different exception when the command length is too long. See https://github.com/Breakthrough/PySceneDetect/issues/164 for details. Arguments: args: List of strings to pass to subprocess.call(). Retu
(args: list[str])
| 219 | |
| 220 | |
| 221 | def invoke_command(args: list[str]) -> int: |
| 222 | """Same as calling Python's subprocess.call() method, but explicitly |
| 223 | raises a different exception when the command length is too long. |
| 224 | |
| 225 | See https://github.com/Breakthrough/PySceneDetect/issues/164 for details. |
| 226 | |
| 227 | Arguments: |
| 228 | args: List of strings to pass to subprocess.call(). |
| 229 | |
| 230 | Returns: |
| 231 | Return code of command. |
| 232 | |
| 233 | Raises: |
| 234 | CommandTooLong: `args` exceeds built in command line length limit on Windows. |
| 235 | """ |
| 236 | try: |
| 237 | return subprocess.call(args) |
| 238 | except OSError as err: |
| 239 | if os.name != "nt": |
| 240 | raise |
| 241 | exception_string = str(err) |
| 242 | # Error 206: The filename or extension is too long |
| 243 | # Error 87: The parameter is incorrect |
| 244 | to_match = ("206", "87") |
| 245 | if any([x in exception_string for x in to_match]): |
| 246 | raise CommandTooLong() from err |
| 247 | raise |
| 248 | |
| 249 | |
| 250 | def get_ffmpeg_path() -> str | None: |