Skip to content

Commit

Permalink
Merge pull request #1805 from OpenC3/improve_openc3cli
Browse files Browse the repository at this point in the history
Improve package install in openc3cli. Includes fix to python install
  • Loading branch information
ryanmelt authored Jan 9, 2025
2 parents a6a9953 + f575fbf commit f061102
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions openc3/bin/openc3cli
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require 'openc3/models/scope_model'
require 'openc3/models/plugin_model'
require 'openc3/models/gem_model'
require 'openc3/models/migration_model'
require 'openc3/models/python_package_model'
require 'openc3/models/tool_model'
require 'openc3/packets/packet_config'
require 'openc3/bridge/bridge'
Expand Down Expand Up @@ -258,6 +259,30 @@ def update_plugin(plugin_file_path, plugin_name, variables: nil, plugin_txt_line
end
end

def wait_process_complete_internal(process_name, scope:)
STDOUT.flush
state = 'Running'
status = nil
while true
status = OpenC3::ProcessStatusModel.get(name: process_name, scope: scope)
state = status['state']
break if state != 'Running'
sleep(5)
print '.'
STDOUT.flush
end
puts "\nFinished: #{state}"
puts "Output:\n"
puts status['output']
if state == 'Complete'
puts "Success!"
exit 0
else
puts "Failed!"
exit 1
end
end

def wait_process_complete(process_name)
STDOUT.flush
state = 'Running'
Expand Down Expand Up @@ -433,7 +458,9 @@ def cli_pkg_install(filename, scope:)
if File.extname(filename) == '.gem'
OpenC3::GemModel.install(filename, scope: scope)
else
OpenC3::PythonPackageModel.install(filename, scope: scope)
process_name = OpenC3::PythonPackageModel.install(filename, scope: scope)
print "Installing..."
wait_process_complete_internal(process_name, scope: scope)
end
else
# Outside Cluster
Expand All @@ -451,7 +478,9 @@ def cli_pkg_uninstall(filename, scope:)
if File.extname(filename) == '.rb'
OpenC3::GemModel.destroy(filename)
else
OpenC3::PythonPackageModel.destroy(filename, scope: scope)
process_name = OpenC3::PythonPackageModel.destroy(filename, scope: scope)
print "Uninstalling..."
wait_process_complete_internal(process_name, scope: scope)
end
else
# Outside Cluster
Expand Down

0 comments on commit f061102

Please sign in to comment.