Skip to content

Fix xtce_converter #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 21, 2022
Merged
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
4 changes: 2 additions & 2 deletions openc3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ case $1 in
# This allows tools running in the container to have a consistent path to the current working directory.
# Run the command "ruby /openc3/bin/openc3cli" with all parameters starting at 2 since the first is 'openc3'
args=`echo $@ | { read _ args; echo $args; }`
docker run --rm -v `pwd`:/openc3/local -w /openc3/local openc3inc/openc3-base:$OPENC3_TAG ruby /openc3/bin/openc3cli $args
docker run --rm --env-file "$(dirname -- "$0")/.env" -v `pwd`:/openc3/local -w /openc3/local openc3inc/openc3-base:$OPENC3_TAG ruby /openc3/bin/openc3cli $args
set +a
;;
cliroot )
set -a
. "$(dirname -- "$0")/.env"
args=`echo $@ | { read _ args; echo $args; }`
docker run --rm --user=root -v `pwd`:/openc3/local -w /openc3/local openc3inc/openc3-base:$OPENC3_TAG ruby /openc3/bin/openc3cli $args
docker run --rm --env-file "$(dirname -- "$0")/.env" --user=root -v `pwd`:/openc3/local -w /openc3/local openc3inc/openc3-base:$OPENC3_TAG ruby /openc3/bin/openc3cli $args
set +a
;;
start )
Expand Down
26 changes: 14 additions & 12 deletions openc3/bin/openc3cli
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

require 'openc3'
require 'openc3/utilities/local_mode'
require 'openc3/utilities/bucket'
require 'openc3/models/scope_model'
require 'openc3/models/plugin_model'
require 'openc3/models/gem_model'
Expand All @@ -39,6 +40,8 @@ require 'erb'
require 'pp'

$redis_url = "redis://#{ENV['OPENC3_REDIS_HOSTNAME']}:#{ENV['OPENC3_REDIS_PORT']}"
# Initialize the connection to the bucket library
OpenC3::Bucket.getClient()

# Build the OpenStruct and OptionParser here as constants so we can use in methods
MIGRATE_OPTIONS = OpenStruct.new
Expand Down Expand Up @@ -242,18 +245,20 @@ def xtce_converter(args)
variables = nil
variables = JSON.parse(File.read(options[:variables]), :allow_nan => true, :create_additions => true) if options[:variables]
puts "Installing #{File.basename(options[:plugin])}"
plugin_hash = OpenC3::PluginModel.install_phase1(options[:plugin], variables, scope: 'DEFAULT', validate_only: true)
plugin_hash = OpenC3::PluginModel.install_phase1(options[:plugin], existing_variables: variables, scope: 'DEFAULT', validate_only: true)
plugin_hash['variables']['xtce_output'] = options[:output]
OpenC3::PluginModel.install_phase2(plugin_hash['name'], plugin_hash['variables'], scope: 'DEFAULT', validate_only: true,
OpenC3::PluginModel.install_phase2(plugin_hash, scope: 'DEFAULT', validate_only: true,
gem_file_path: options[:plugin])
result = 0 # bash and Windows consider 0 success
rescue => e
puts "Error: #{e.message}"
puts e.backtrace
result = ERROR_CODE
ensure
name = Psych.safe_load(`gem spec #{options[:plugin]} name`).to_s
version = Psych.safe_load(`gem spec #{options[:plugin]} version`, permitted_classes: [Gem::Version]).to_s
Gem::Uninstaller.new(name, {:version => version, :force => true}).uninstall
# Uninstall not necessary because this is run against a temporary container
# name = Psych.safe_load(`gem spec #{options[:plugin]} name`).to_s
# version = Psych.safe_load(`gem spec #{options[:plugin]} version`, permitted_classes: [Gem::Version]).to_s
# Gem::Uninstaller.new(name, {:version => version, :force => true}).uninstall
exit(result)
end
else
Expand Down Expand Up @@ -305,13 +310,10 @@ rescue => e
puts "Error: #{e.message}"
result = ERROR_CODE
ensure
begin
name = Psych.safe_load(`gem spec #{plugin_file_path} name`).to_s
version = Psych.safe_load(`gem spec #{plugin_file_path} version`, permitted_classes: [Gem::Version]).to_s
Gem::Uninstaller.new(name, {:version => version, :force => true}).uninstall
rescue => e
puts "Could not uninstall #{plugin_file_path} due to #{e.message}"
end
# Uninstall not necessary because this is run against a temporary container
# name = Psych.safe_load(`gem spec #{plugin_file_path} name`).to_s
# version = Psych.safe_load(`gem spec #{plugin_file_path} version`, permitted_classes: [Gem::Version]).to_s
# Gem::Uninstaller.new(name, {:version => version, :force => true}).uninstall
exit(result)
end

Expand Down
2 changes: 1 addition & 1 deletion openc3/data/config/target.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
TARGET:
summary: Defines a new target
example: TARGET INST
example: TARGET INST INST
parameters:
- name: Folder Name
required: true
Expand Down