allow multiple filename arguments to db_import and handle globs, see 750
git-svn-id: file:///home/svn/framework3/trunk@8089 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
dd180a850b
commit
93a673fa1f
|
@ -950,7 +950,6 @@ class DBManager
|
|||
else
|
||||
doc = REXML::Document.new(data)
|
||||
end
|
||||
p doc.root
|
||||
doc.elements.each('/NeXposeSimpleXML/devices/device') do |dev|
|
||||
addr = dev.attributes['address'].to_s
|
||||
desc = ''
|
||||
|
|
|
@ -829,15 +829,29 @@ class Db
|
|||
# Generic import that automatically detects the file type
|
||||
#
|
||||
def cmd_db_import(*args)
|
||||
if (not (args and args.length == 1))
|
||||
print_error("Usage: db_import <filename>")
|
||||
if (args.include?("-h") or not (args and args.length > 0))
|
||||
print_error("Usage: db_import <filename> [file2...]")
|
||||
print_line
|
||||
print_line("filenames can be globs like *.xml, or **/*.xml which will search recursively")
|
||||
return
|
||||
end
|
||||
if (not File.readable?(args[0]))
|
||||
print_error("Could not read the file")
|
||||
return
|
||||
end
|
||||
framework.db.import_file(args[0])
|
||||
args.each { |glob|
|
||||
Dir.glob(File.expand_path(glob)).each { |filename|
|
||||
if (not File.readable?(filename))
|
||||
print_error("Could not read file #{filename}")
|
||||
next
|
||||
end
|
||||
begin
|
||||
framework.db.import_file(filename)
|
||||
print_status("Successfully imported #{filename}")
|
||||
rescue DBImportError
|
||||
print_error("Failed to import #{filename}: #{$!.class}: #{$!}")
|
||||
elog("Failed to import #{filename}: #{$!.class}: #{$!}", LEV_1)
|
||||
dlog("Call stack: #{$@.join("\n")}", LEV_3)
|
||||
next
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue