Skip to content

Commit

Permalink
Merge pull request #24 from efabless/fix_ls_local
Browse files Browse the repository at this point in the history
fixed the ls local command to use both json and yaml
  • Loading branch information
jeffdi authored Jul 2, 2024
2 parents 07b0575 + 2050855 commit 590f023
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions ipm/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import click
import httpx
import yaml
from rich.console import Console
from rich.table import Table
from bs4 import BeautifulSoup
Expand Down Expand Up @@ -165,14 +166,33 @@ def get_installed_ip_info(ipm_root):
Returns:
list: list of dicts of all installed ips and their data
"""
logger = Logger()
installed_ips = IPInfo.get_installed_ips(ipm_root)
installed_ips_arr = []
for ips in installed_ips:
for ip_name, ip_version in ips.items():
for version in ip_version:
json_file = f"{ipm_root}/{ip_name}/{version}/{ip_name}.json"
with open(json_file) as f:
data = json.load(f)
yaml_file = f"{ipm_root}/{ip_name}/{version}/{ip_name}.yaml"
config_path = None
if os.path.exists(json_file):
config_path = json_file
elif os.path.exists(yaml_file):
config_path = yaml_file
else:
logger.print_err(
f"Can't find {json_file} or {yaml_file}. Please refer to the IPM directory structure (IP name {self.ip_name} might be wrong)."
)
return False

if config_path.endswith('.json'):
with open(config_path) as config_file:
data = json.load(config_file)
else:
with open(config_path) as config_file:
data = yaml.safe_load(config_file)
# with open(json_file) as f:
# data = json.load(f)
installed_ips_arr.append({data["info"]["name"]: data})
return installed_ips_arr

Expand Down Expand Up @@ -537,11 +557,13 @@ def create_table(ip_list, version=None, extended=False, local=False):
table.add_column("Status")
if extended:
table.add_column("Bus")
table.add_column("Cell count")
table.add_column("Clk freq (MHz)")
if not local:
table.add_column("Cell count")
table.add_column("Clk freq (MHz)")
table.add_column("Width (um)")
table.add_column("Height (um)")
table.add_column("Voltage (v)")
if not local:
table.add_column("Voltage (v)")
table.add_column("Technology", style="cyan")
table.add_column("License", style="magenta")

Expand Down Expand Up @@ -591,11 +613,11 @@ def create_table(ip_list, version=None, extended=False, local=False):
table_list.append(value["info"]["status"])
if extended:
table_list.append(",".join(value["info"]["bus"]))
table_list.append(value["info"]["cell_count"])
table_list.append(value["info"]["clock_freq_mhz"])
# table_list.append(value["info"]["cell_count"])
# table_list.append(value["info"]["clock_freq_mhz"])
table_list.append(value["info"]["width"])
table_list.append(value["info"]["height"])
table_list.append(",".join(value["info"]["supply_voltage"]))
# table_list.append(",".join(value["info"]["supply_voltage"]))
table_list.append(value["info"]["technology"])
table_list.append(value["info"]["license"])
table.add_row(*table_list)
Expand Down

0 comments on commit 590f023

Please sign in to comment.