Merge pull request #2866 from lbryio/dont_shlex_windows

fixed issue with shell parsing on Windows
This commit is contained in:
Lex Berezhny 2020-03-19 17:53:47 -04:00 committed by GitHub
commit 17789bc814
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,6 +3,7 @@ import json
import logging
import os
import pathlib
import platform
import re
import shlex
import shutil
@ -35,13 +36,11 @@ class VideoFileAnalyzer:
@staticmethod
def _execute(command, environment):
args = shlex.split(command)
# if log.isEnabledFor(logging.DEBUG):
# log.debug("Executing: %s", " ".join(args))
# log.debug("Executing: %s", command)
try:
with subprocess.Popen(
args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environment
shlex.split(command) if platform.system() != 'Windows' else command,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=environment
) as process:
(stdout, stderr) = process.communicate() # blocks until the process exits
return stdout.decode(errors='replace') + stderr.decode(errors='replace'), process.returncode