Skip to content

Commit

Permalink
fix: implement feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
MaferMazu committed Aug 20, 2024
1 parent e55f4b9 commit 1fbb414
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions tutorpicasso/commands/enable_private_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def enable_private_packages() -> None:
defining them as private.
Raises:
Exception: If an error occurs during the cloning or defining process.
Exception: If there is not enough information to clone the repo.
"""
context = click.get_current_context().obj
tutor_root = context.root
Expand All @@ -41,39 +41,33 @@ def enable_private_packages() -> None:
file.write("")

for package, info in packages.items():
try:
if not {"name", "repo", "version"}.issubset(info):
raise KeyError(
f"{package} is missing one of the required keys: 'name', 'repo', 'version'"
)

if os.path.isdir(f'{private_requirements_root}/{info["name"]}'):
subprocess.call(
["rm", "-rf", f'{private_requirements_root}/{info["name"]}']
)
if not {"name", "repo", "version"}.issubset(info):
raise click.ClickException(
f"{package} is missing one of the required keys: 'name', 'repo', 'version'"
)

if os.path.isdir(f'{private_requirements_root}/{info["name"]}'):
subprocess.call(
["git", "clone", "-b", info["version"], info["repo"]],
cwd=private_requirements_root,
["rm", "-rf", f'{private_requirements_root}/{info["name"]}']
)

if tutor_version_obj < quince_version_obj:
echo_command = (
f'echo "-e ./{info["name"]}/" >> {private_requirements_txt}'
)
subprocess.call(echo_command, shell=True)
else:
subprocess.call(
[
"tutor",
"mounts",
"add",
f'{private_requirements_root}/{info["name"]}',
]
)
subprocess.call(
["git", "clone", "-b", info["version"], info["repo"]],
cwd=private_requirements_root,
)

except KeyError as e:
raise click.ClickException(str(e))
if tutor_version_obj < quince_version_obj:
echo_command = f'echo "-e ./{info["name"]}/" >> {private_requirements_txt}'
subprocess.call(echo_command, shell=True)
else:
subprocess.call(
[
"tutor",
"mounts",
"add",
f'{private_requirements_root}/{info["name"]}',
]
)


def get_picasso_packages(settings: Dict[str, Any]) -> Dict[str, Dict[str, Any]]:
Expand Down

0 comments on commit 1fbb414

Please sign in to comment.