Project

General

Profile

« Previous | Next » 

Revision ec7296ea

Added by Marc Dequènes about 13 years ago

  • ID ec7296ea2492f2337a9b7dc2de8041d1327cb492

[fix] Interface: intercept several possible errors around interface definition

View differences:

lib/cyborghood/cyborg/botnet/interface.rb
cleanup
end
def root?
@parent_node.nil?
end
def hidden?
@hidden
end
def node_path
return '/' if root?
path = @parent_node.node_path
path += "/" + @node_name unless @node_name.empty?
path.gsub("//", "/")
end
def add_behavior(&block)
if block_given?
@blocks << block
else
return if @ldir_loaded
Dir.glob(File.join(self.lpath, '*.rb')) do |file|
logger.debug "Interface: loading file '#{file}'"
@blocks << File.read(file)
begin
Dir.glob(File.join(self.lpath, '*.rb')) do |file|
logger.debug "Interface: loading file '#{file}'"
begin
@blocks << File.read(file)
rescue
logger.error "Interface: definition file '#{file}' cannot be read"
end
end
rescue
logger.error "Interface: directory '#{self.lpath}' cannot be read"
end
@ldir_loaded = true
......
match_list.each do |child_node_name|
node.__send__(:load, child_node_name)
result = node.__send__(:request, request.session)
next unless result.respond_to? :to_hash
if hash_match_criterias(result, request.args.first)
if hash_match_criterias(result.to_hash, request.args.first)
node_names_list << child_node_name
end
end
......
protected
def root?
@parent_node.nil?
end
def base_lpath
File.join(Config::LIB_DIR, 'cyborghood-' + @bot.name.downcase, 'interface')
end
......
cleanup
@node_name = node_element
@blocks.each do |bl|
if bl.is_a? String
instance_eval bl
else
instance_eval &bl
begin
if bl.is_a? String
instance_eval bl
else
instance_eval &bl
end
rescue Exception => e
logger.error "Interface: a definition block for node '#{node_path}' is buggy: " + e.message
end
end
end

Also available in: Unified diff