I don't know what's going on. A script run by Django works fine, but not through Docker and Django. An error is returned:
Pic Errno 2 No such file or directory
Below is the code of the function with the error and the code of the Dockerfile.
'''
def mediainfo(filepath):
Original code:
prober = get_prober_name() command_args = [ "-v", "quiet", "-show_format", "-show_streams", filepath ] command = [prober, '-of', 'old'] + command_args
Modified code:
command = f"ffprobe -v error -show_format -show_streams -select_streams v:0 {filepath}"
The rest of the functions:
res = Popen(command, stdout=PIPE)
output = res.communicate()[0].decode("utf-8")
if res.returncode != 0:
output = Popen(command, stdout=PIPE).communicate()[0].decode("utf-8")
rgx = re.compile(r"(?:(?P<inner_dict>.*?):)?(?P<key>.*?)\=(?P<value>.*?)$")
info = {}
if sys.platform == 'win32':
output = output.replace("\r", "")
for line in output.split("\n"):
# print(line)
mobj = rgx.match(line)
if mobj:
# print(mobj.groups())
inner_dict, key, value = mobj.groups()
if inner_dict:
try:
info[inner_dict]
except KeyError:
info[inner_dict] = {}
info[inner_dict][key] = value
else:
info[key] = value
return info
'''
Code of the Dockerfile
'''
FROM python:3.7 as base
EXPOSE 80
WORKDIR /app
COPY . /app
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
RUN pip install --upgrade pip
RUN echo 'deb http://deb.debian.org/debian buster-backports main contrib non-free' >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get -y install ffmpeg
RUN apt-get update
COPY requirements.txt .
RUN python -m pip install -r requirements.txt
FROM base as prod
ENTRYPOINT ["python","manage.py","runserver","0.0.0.0:80"]
'''