Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions robotpy_installer/roborio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@ def uninstall_cpp_java_admin(ssh: SshController):

def get_rio_py_packages(ssh: SshController) -> typing.Dict[str, str]:
# Use importlib.metadata instead of pip because it's way faster than pip
result = ssh.exec_cmd(
output = ssh.check_output(
"/usr/local/bin/python3 -c "
"'from importlib.metadata import distributions;"
"import json; import sys; "
"json.dump({dist.name: dist.version for dist in distributions()},sys.stdout)'",
get_output=True,
)
assert result.stdout is not None
d = json.loads(result.stdout)
d = json.loads(output)
# sometimes distributions.name or version is None
return {k: v for k, v in d.items() if k and v}

Expand Down
5 changes: 5 additions & 0 deletions robotpy_installer/sshcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ def exec_cmd(
retval = channel.recv_exit_status()

if check and retval != 0:
if not print_output:
Comment thread
auscompgeek marked this conversation as resolved.
try:
print(buffer.getvalue(), file=sys.stderr)
except UnicodeEncodeError:
pass
raise SshExecError(
"Command '%s' returned non-zero error status %s" % (cmd, retval),
retval,
Expand Down