diff --git a/tutorpicasso/commands/enable_private_packages.py b/tutorpicasso/commands/enable_private_packages.py index 64721c3..77ee442 100644 --- a/tutorpicasso/commands/enable_private_packages.py +++ b/tutorpicasso/commands/enable_private_packages.py @@ -40,11 +40,18 @@ def enable_private_packages() -> None: ["rm", "-rf", f'{private_requirements_path}/{info["name"]}'] ) - subprocess.call( + process = subprocess.run( ["git", "clone", "-b", info["version"], info["repo"]], cwd=private_requirements_path, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, ) + click.echo(process.stdout) + if process.stderr: + click.echo(process.stderr) + handle_private_requirements_by_tutor_version(info, private_requirements_path) @@ -83,7 +90,19 @@ def _enable_private_requirements_before_quince( file.write("") echo_command = f'echo "-e ./{info["name"]}/" >> {private_requirements_txt}' - subprocess.call(echo_command, shell=True) + + process = subprocess.run( + echo_command, + shell=True, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ) + + click.echo(process.stdout) + + if process.stderr: + click.echo(process.stderr) def _enable_private_requirements_latest( @@ -96,15 +115,23 @@ def _enable_private_requirements_latest( info (Dict[str, str]): A dictionary containing metadata about the requirement. Expected to have a "name" key. private_requirements_path (str): The root directory where private requirements are stored. """ - subprocess.call( + process = subprocess.run( [ "tutor", "mounts", "add", f'{private_requirements_path}/{info["name"]}', - ] + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, ) + click.echo(process.stdout) + + if process.stderr: + click.echo(process.stderr) + def get_picasso_packages(settings: Dict[str, Any]) -> Dict[str, Dict[str, Any]]: """ diff --git a/tutorpicasso/commands/enable_themes.py b/tutorpicasso/commands/enable_themes.py index a97e24f..a585bfb 100644 --- a/tutorpicasso/commands/enable_themes.py +++ b/tutorpicasso/commands/enable_themes.py @@ -25,16 +25,38 @@ def enable_themes() -> None: # because it comes from the Tutor framework. # We are not handle type errors related to this object. for theme in tutor_conf["PICASSO_THEMES"]: # type: ignore - if not {"name", "repo", "version"}.issubset(theme.keys()): # type: ignore + if not isinstance(theme, dict): raise click.ClickException( - f"{theme} is missing one or more required keys: " - "'name', 'repo', 'version'" + "Expected 'theme' to be a dictionary, but got something else." ) - theme_path = f'{tutor_root}/env/build/openedx/themes/{theme["name"]}' # type: ignore - if os.path.isdir(theme_path): - subprocess.call(["rm", "-rf", theme_path]) + else: + if not {"name", "repo", "version"}.issubset(theme.keys()): + raise click.ClickException( + f"{theme} is missing one or more required keys: " + "'name', 'repo', 'version'" + ) + + theme_path = f'{tutor_root}/env/build/openedx/themes/{theme["name"]}' + if os.path.isdir(theme_path): + subprocess.call(["rm", "-rf", theme_path]) + + theme_version = theme.get("version", "") + theme_repo = theme.get("repo", "") + process = subprocess.run( + [ + "git", + "clone", + "-b", + str(theme_version), + str(theme_repo), + str(theme_path), + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + ) - subprocess.call( - ["git", "clone", "-b", theme["version"], theme["repo"], theme_path], # type: ignore - ) + click.echo(process.stdout) + if process.stderr: + click.echo(process.stderr)