Skip to content

Commit

Permalink
fix: freeze when 'enable-themes' was execute twice
Browse files Browse the repository at this point in the history
When 'enable-themes' was executed before, a new execution failed overriding the existing folder
  • Loading branch information
bra-i-am committed Jun 27, 2024
1 parent 885e0b9 commit 1924007
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions tutordistro/distro/extra_commands/infrastructure/tutor_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,24 @@ def run_command(self, command: str):
command (str): Tutor command.
"""
try:
process = subprocess.run(
print(f'Running "{command}"')

with subprocess.Popen(
command,
shell=True,
check=True,
capture_output=True,
executable="/bin/bash",
)
# This print is left on purpose to show the command output
print(process.stdout.decode())
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
) as process:

stdout, stderr = process.communicate(input="y")

if process.returncode != 0 or "error" in stderr.lower():
raise subprocess.CalledProcessError(
process.returncode, command, output=stdout, stderr=stderr
)

except subprocess.CalledProcessError as error:
raise CommandError(
f"Error running command '{error.cmd}':\n{error.stderr.decode()}"
) from error
raise CommandError(f"\n{error.stderr}") from error

0 comments on commit 1924007

Please sign in to comment.