Skip to content

Commit

Permalink
Fix ruby python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthomas committed Sep 27, 2023
1 parent ad3f682 commit daa7d36
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion openc3/lib/openc3/microservices/microservice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def as_json(*a)
end

def initialize(name, is_plugin: false)
@shutdown_complete = false
Logger.info("Microservice running from: ruby #{$0} #{ARGV.join(" ")}")
raise "Microservice must be named" unless name

Expand Down Expand Up @@ -199,14 +200,15 @@ def run
end

def shutdown
# TODO: Flag so this doesn't get run twice ... see python
return if @shutdown_complete
@logger.info("Shutting down microservice: #{@name}")
@cancel_thread = true
@microservice_status_sleeper.cancel if @microservice_status_sleeper
MicroserviceStatusModel.set(as_json(:allow_nan => true), scope: @scope)
FileUtils.remove_entry(@temp_dir) if File.exist?(@temp_dir)
@metric.shutdown
@logger.info("Shutting down microservice complete: #{@name}")
@shutdown_complete = true
end
end
end
7 changes: 3 additions & 4 deletions openc3/lib/openc3/models/interface_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,12 @@ def initialize(
unless @cmd
type = self.class._get_type
microservice_name = "#{@scope}__#{type}__#{@name}"
if File.extname(config_params[0]) == '.rb'
@cmd = ["ruby", "#{type.downcase}_microservice.rb", microservice_name]
elsif File.extname(config_params[0]) == '.py'
if config_params[0] and File.extname(config_params[0]) == '.py'
work_dir.sub!('openc3/lib', 'openc3/python')
@cmd = ["python", "#{type.downcase}_microservice.py", microservice_name]
else
raise "Unknown file type #{config_params[0]}"
# If there are no config_params we assume ruby
@cmd = ["ruby", "#{type.downcase}_microservice.rb", microservice_name]
end
end
@work_dir = work_dir
Expand Down
4 changes: 3 additions & 1 deletion openc3/python/openc3/packets/parsers/processor_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def create_processor(self, packet):
)
else:
processor = klass()
if not issubclass(type(processor), Processor):
# NOTE: issubclass is not reliable ...
# if not issubclass(type(processor), Processor):
if "Processor" not in processor.__class__.__name__:
raise AttributeError(
f"processor must be a Processor but is a {processor.__class__.__name__}"
)
Expand Down

0 comments on commit daa7d36

Please sign in to comment.