Why does trying to call this external program from a Python script result in errors?

4 hours ago 3
ARTICLE AD BOX

So I'm stumped. I'm trying to call Martchus' tageditor from Python and while I can use the command in a command window just fine I keep getting an error trying to call it from Python.

import os import subprocess # Specify the export path and file format export_path = "C:\\Users\\lords\\Videos\\MCOC Videos\\" #file_prefix = project.GetName() file_prefix = "Untitled Project 2" file_format = "jpg" filepath = os.path.join(export_path, file_prefix + "." + file_format) cmd = [ "tageditor-cli", f'set cover="{filepath}"', f'-f "{os.path.join(export_path, file_prefix)}.mp4"' ] #cmd = f"tageditor-cli set cover=\"{filepath}\" -f \"{os.path.join(export_path, file_prefix)}.mp4\"" try: result = subprocess.run( cmd, capture_output=True, timeout=10, check=True ) print(result.stdout) except subprocess.TimeoutExpired: print("The command timed out.") except subprocess.CalledProcessError as e: print(f"Command failed with exit code {e.returncode} {e.stderr}")

When run it results in this:

['tageditor-cli', "set cover'=C:\\Users\\lords\\Videos\\MCOC Videos\\Untitled Project 2.jpg'", '-f %C:\\Users\\lords\\Videos\\MCOC Videos\\Untitled Project 2.mp4%'] Command failed with exit code 1 b'Error: Unable to parse arguments: The argument "file" mustn\'t be specified more than 1 time.\r\nSee --help for available commands.\r\n'

Since posting this I did get it to work by using that second cmd assignment but I don't know why the array version didn't work.

Edit: After looking at a similar post I tried this:

cmd = [ "tageditor-cli", 'set', 'cover=', str('"' + shlex.quote(filepath) + '"'), '-f', str(shlex.quote(export_path + file_prefix + ".mp4"))

]

Read Entire Article