Skip to content

Commit

Permalink
fix update command
Browse files Browse the repository at this point in the history
  • Loading branch information
Marwan Abbas authored and Marwan Abbas committed Jul 2, 2024
1 parent 9799d89 commit 7fc89ff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
31 changes: 31 additions & 0 deletions ipm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,37 @@ def list_installed_ips(ipm_root):
ip_data = IPInfo.get_installed_ip_info(ipm_root)
IP.create_table(ip_data, local=True, extended=True)

def update_ips(ipm_root, ip_root=None):
"""checks if the ips installed have newer versions
Args:
ipm_root (str): path to common installation path
update (bool, optional): if True, will check and update. Defaults to False.
ip_root (str, optional): path to the project ip dict. Defaults to None.
"""
logger = Logger()
root = IPRoot(ipm_root, ip_root)
installed_ips = root.get_dependencies_object()
if len(installed_ips["IP"]) > 0:
for ips in installed_ips["IP"]:
for ip_name, ip_version in ips.items():
verified_ip_info = IPInfo.get_verified_ip_info(ip_name)
version = get_latest_version(verified_ip_info["release"])
if version not in ip_version:
logger.print_info(
f"Updating IP {ip_name} to [magenta]{version}[/magenta]…"
)
ip = IP.find_verified_ip(ip_name, version, ipm_root)
root.try_add(ip)
else:
logger.print_info(
f"IP {ip_name} is the newest version [magenta]{version}[/magenta]."
)
else:
logger.print_warn(
f"No IPs in your project to be updated."
)


def check_ips(ipm_root, update=False, ip_root=None):
"""checks if the ips installed have newer versions
Expand Down
3 changes: 2 additions & 1 deletion ipm/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
package_check,
rm_ip_from_project,
uninstall_ip,
update_ips,
)


Expand Down Expand Up @@ -191,7 +192,7 @@ def update_cmd(ipm_root, ip_root):
valid = check_ipm_directory(ipm_root)
valid_ip_dir = check_ip_root_dir(ip_root)
if valid and valid_ip_dir:
check_ips(ipm_root, update=True, ip_root=ip_root)
update_ips(ipm_root, ip_root=ip_root)


@click.command("package-check", hidden=True)
Expand Down

0 comments on commit 7fc89ff

Please sign in to comment.