Skip to content

Commit

Permalink
Merge pull request #386 from rapyuta-robotics/devel
Browse files Browse the repository at this point in the history
🎉 release: 9.2.0
  • Loading branch information
pallabpain authored Nov 14, 2024
2 parents 599da72 + ee17ae8 commit b5c3a62
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/upload-appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
MINIO_SECRET: ${{ secrets.MINIO_SECRET }}

- name: Upload AppImage artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: appimages
path: ${{ github.workspace }}/scripts/rio*.AppImage
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
"python-magic>=0.4.27",
"pytz",
"pyyaml>=5.4.1",
"rapyuta-io>=2.0.0",
"rapyuta-io>=2.1.1",
"requests>=2.20.0",
"semver>=3.0.0",
"setuptools",
Expand Down
43 changes: 39 additions & 4 deletions riocli/apply/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Filters to use in the manifests.
"""

import os

from riocli.config import new_client
from riocli.device.util import find_device_guid


def getenv(default: str, env_var: str) -> str:
"""
Get the value of an environment variable.
"""Get the value of an environment variable.
Usage:
"foo" : {{ "bar" | getenv('FOO') }}
Expand All @@ -36,6 +36,41 @@ def getenv(default: str, env_var: str) -> str:
return os.getenv(env_var, default)


def get_interface_ip(device_name: str, interface: str) -> str:
"""Get the IP address of an interface on a device.
Usage:
"ip" : {{ device_name | get_intf_ip(interface='intf-name') }}
Args:
device_name: The name of the device.
interface: The name of the interface.
Returns:
The IP address of the interface
Raises:
Exception: If the interface is not available on the device.
"""
client = new_client(with_project=True)
device_id = find_device_guid(client, device_name)

device = client.get_device(device_id)
try:
device.poll_till_ready(retry_count=50, sleep_interval=10)
except Exception as e:
raise e

device.refresh()

for name in device.ip_interfaces:
if name == interface:
return device.ip_interfaces[name][0]

raise Exception(f'interface "{interface}" not found on device "{device_name}"')


FILTERS = {
"getenv": getenv,
"get_intf_ip": get_interface_ip,
}
12 changes: 10 additions & 2 deletions riocli/device/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# limitations under the License.
import click
from click_help_colors import HelpColorsCommand

from riocli.config import new_client
from rapyuta_io.clients.device import DeviceStatus
from riocli.constants import Colors, Symbols
from riocli.device.util import name_to_guid, generate_shared_url, upload_debug_logs
from riocli.utils.spinner import with_spinner
Expand Down Expand Up @@ -76,6 +77,14 @@ def report_device(
$ rio device report -s -e 10 DEVICE_NAME
"""
device = new_client().get_device(device_guid)
if device["status"] != DeviceStatus.ONLINE:
spinner.text = click.style(
"Device is not online. Skipping report.", fg=Colors.YELLOW
)
spinner.yellow.ok(Symbols.WARNING)
return

if not force:
with spinner.hidden():
click.confirm(
Expand All @@ -95,7 +104,6 @@ def report_device(

spinner.text = click.style("Device reported successfully.", fg=Colors.GREEN)
spinner.green.ok(Symbols.SUCCESS)

except Exception as e:
spinner.text = click.style("Failed to report device: {}".format(e), fg=Colors.RED)
spinner.red.fail(Symbols.ERROR)
2 changes: 1 addition & 1 deletion riocli/organization/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def list_organizations(ctx: click.Context) -> None:
try:
client = new_client(with_project=False)
organizations = client.get_user_organizations()
current = ctx.obj.data["organization_id"]
current = ctx.obj.data.get("organization_id")
print_organizations(organizations, current)
except Exception as e:
click.secho(str(e), fg=Colors.RED)
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5c3a62

Please sign in to comment.