Fix shenanigans with subprocess.Popen and the text argument with rhel

This commit is contained in:
Théophile Diot 2024-08-08 17:07:32 +01:00
parent 1f1612165a
commit 247cf2b215
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
4 changed files with 7 additions and 7 deletions

View file

@ -37,7 +37,7 @@ RUN export MAKEFLAGS="-j$(nproc)" && \
# Install node and npm to build vite frontend
RUN curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - && \
dnf install -y --setopt=install_weak_deps=False nodejs
dnf install -y --setopt=install_weak_deps=False nodejs
# Copy files
# can't exclude deps from . so we are copying everything by hand

View file

@ -48,7 +48,7 @@ RUN export MAKEFLAGS="-j$(nproc)" && \
# Install node and npm to build vite frontend
RUN curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - && \
dnf install -y --setopt=install_weak_deps=False nodejs
dnf install -y --setopt=install_weak_deps=False nodejs
# Copy files
# can't exclude deps from . so we are copying everything by hand

View file

@ -51,7 +51,7 @@ RUN export MAKEFLAGS="-j$(nproc)" && \
# Install node and npm to build vite frontend
RUN curl -fsSL https://rpm.nodesource.com/setup_20.x | bash - && \
dnf install -y --setopt=install_weak_deps=False nodejs
dnf install -y --setopt=install_weak_deps=False nodejs
# Copy files
# can't exclude deps from . so we are copying everything by hand

View file

@ -46,16 +46,16 @@ def run_command(command: List[str]) -> int:
"""Utils to run a subprocess command. This is usefull to run npm commands to build vite project"""
print(f"Running command: {command}", flush=True)
try:
process = Popen(command, stdout=PIPE, stderr=PIPE, cwd=current_directory.as_posix(), shell=not bool(getenv("DOCKERFILE", "")), text=True)
process = Popen(command, stdout=PIPE, stderr=PIPE, cwd=current_directory.as_posix(), shell=not bool(getenv("DOCKERFILE", "")))
while process.poll() is None:
if process.stdout is not None:
for line in process.stdout:
print(line.strip(), flush=True)
print(line.decode("utf-8").strip(), flush=True)
if process.returncode != 0:
print("Error while running command", flush=True)
print(process.stdout.read(), flush=True)
print(process.stderr.read(), flush=True)
print(process.stdout.read().decode("utf-8"), flush=True)
print(process.stderr.read().decode("utf-8"), flush=True)
return 1
except BaseException as e:
print(f"Error while running command: {e}", flush=True)