Skip to content

Commit

Permalink
Improve info
Browse files Browse the repository at this point in the history
  • Loading branch information
rbonghi committed Jan 20, 2025
1 parent cbaf038 commit aa92f25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
23 changes: 17 additions & 6 deletions src/nanosaur/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from jtop import jtop, JtopException

from nanosaur import __version__
from nanosaur.utilities import Params
from nanosaur.utilities import Params, get_nanosaur_home
from nanosaur import workspace
from nanosaur import simulation
from nanosaur import robot
Expand All @@ -54,18 +54,26 @@

def info(platform, params: Params, args):
"""Print version information."""
# Print mode if it exists in params
if 'mode' in params:
print(TerminalFormatter.color_text(f"Mode: {params['mode']}", bg_color='red', bold=True))
print()

robot_list = robot.RobotList.load(params)
# Print current robot configuration
robot_data = robot.RobotList.get_robot(params)
robot_data.verbose()

robot_list = robot.RobotList.load(params)
# Print other robots if they exist
if len(robot_list.robots) > 1:
print("\nOther robots:")
for i, rb in enumerate(robot_list.robots):
if i != params.get('robot_idx', 0):
print(f"{i}. {rb}")

# Print simulation tools if they exist
if 'simulation_tool' in params:
print(f"\n{TerminalFormatter.color_text('Simulation Tool:', bold=True)} {params['simulation_tool']}")

# Print all workspaces installed
print(TerminalFormatter.color_text("\nInstalled Workspaces:", bold=True))
for ws_name in ['ws_perception_name', 'ws_robot_name', 'ws_simulation_name']:
Expand All @@ -87,7 +95,10 @@ def info(platform, params: Params, args):
for key, value in platform.items():
print(f" {key}: {value}")
# Print version information
print(f"Nanosaur package version {__version__}")
print(TerminalFormatter.color_text("\nVersion Information:", bold=True))
print(f" {TerminalFormatter.color_text('Nanosaur package:', bold=True)} {__version__}")
print(f" {TerminalFormatter.color_text('Nanosaur version (branch):', bold=True)} {params['nanosaur_branch']}")
print(f" {TerminalFormatter.color_text('Nanosaur home:', bold=True)} {get_nanosaur_home(params['nanosaur_home'])}")


def install(platform, params: Params, args, password=None):
Expand Down Expand Up @@ -192,7 +203,7 @@ def main():

# Subcommand: install (hidden if workspace already exists)
# if get_workspace_path(params['nanosaur_workspace_name']) is None:
if 'developer_mode' not in params and not params['developer_mode']:
if 'mode' in params and params['mode'] == 'developer':
parser_install = subparsers.add_parser('install', help="Install the Nanosaur workspace")
else:
parser_install = subparsers.add_parser('install')
Expand All @@ -203,7 +214,7 @@ def main():
parser_install.set_defaults(func=install)

# Subcommand: workspace (with a sub-menu for workspace operations)
if 'developer_mode' in params and params['developer_mode']:
if 'mode' in params and params['mode'] == 'developer':
# Add workspace subcommand
parser_workspace = parser_workspace_menu(subparsers)

Expand Down
3 changes: 3 additions & 0 deletions src/nanosaur/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def __repr__(self):
def to_dict(self) -> list:
return [robot.to_dict() for robot in self.robots]

def print_all_robots(self):
for robot in self.robots:
print(robot)

class Params:

Expand Down
2 changes: 1 addition & 1 deletion src/nanosaur/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def create_developer_workspace(platform, params: Params, args, password=None):
ws_name_path = create_workspace(nanosaur_home_path, params['ws_perception_name'])
build_workspace(branch, ws_name_path, 'perception', password, skip_rosdep=True, skip_build=True)
# Set params in developer mode
params['developer_mode'] = True
params['mode'] = 'developer'


def download_rosinstall(url, folder_path, file_name) -> str:
Expand Down

0 comments on commit aa92f25

Please sign in to comment.