Skip to content

Commit

Permalink
update to have a specific ip argument
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 7fc89ff commit 0a34a4a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 15 additions & 1 deletion ipm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,20 +1052,34 @@ 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):
def update_ips(ipm_root, ip_root=None, ip_to_update=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.
update_ip (str, optional): Name of the IP to be updated. Defaults to None.
"""
logger = Logger()
root = IPRoot(ipm_root, ip_root)
installed_ips = root.get_dependencies_object()

if ip_to_update:
ip_found = False
for ips in installed_ips["IP"]:
if ip_to_update in ips:
ip_found = True
break
if not ip_found:
logger.print_err(f"The IP '{ip_to_update}' is not installed.")
return

if len(installed_ips["IP"]) > 0:
for ips in installed_ips["IP"]:
for ip_name, ip_version in ips.items():
if ip_to_update and ip_name != ip_to_update:
continue # Skip IPs that do not match the update_ip argument
verified_ip_info = IPInfo.get_verified_ip_info(ip_name)
version = get_latest_version(verified_ip_info["release"])
if version not in ip_version:
Expand Down
7 changes: 4 additions & 3 deletions ipm/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,16 @@ def check_cmd(ipm_root):

@click.command("update")
@opt_ipm_root
@click.argument("ip", required=False)
@click.option(
"--ip-root", required=False, default=os.path.join(os.getcwd(), "ip"), help="IP path"
)
def update_cmd(ipm_root, ip_root):
"""Check for new versions of all installed IPs or a specific IP."""
def update_cmd(ipm_root, ip_root, ip):
"""Check for new versions of all installed IPs in project or a specific IP."""
valid = check_ipm_directory(ipm_root)
valid_ip_dir = check_ip_root_dir(ip_root)
if valid and valid_ip_dir:
update_ips(ipm_root, ip_root=ip_root)
update_ips(ipm_root, ip_root=ip_root, ip_to_update=ip)


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

0 comments on commit 0a34a4a

Please sign in to comment.