diff options
| author | Luc Donnet | 2018-03-12 15:09:55 +0100 |
|---|---|---|
| committer | GitHub | 2018-03-12 15:09:55 +0100 |
| commit | 10765f6378777d74b121faf9e6f2a17a9fb1594e (patch) | |
| tree | c6ddba1633e7243d5dab189fd3e199e731d21cc2 /lib/tasks/helpers | |
| parent | 43a5e136c1b35483675918120405cd4f5bea3397 (diff) | |
| parent | b7079226c965e7130a2bcc17b7f278a1e23ac7e8 (diff) | |
| download | chouette-core-10765f6378777d74b121faf9e6f2a17a9fb1594e.tar.bz2 | |
Merge pull request #361 from af83/6068-simple-exporter
6068 simple exporter
Diffstat (limited to 'lib/tasks/helpers')
| -rw-r--r-- | lib/tasks/helpers/simple_interfaces.rb | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/lib/tasks/helpers/simple_interfaces.rb b/lib/tasks/helpers/simple_interfaces.rb index 5b593be43..61dd38399 100644 --- a/lib/tasks/helpers/simple_interfaces.rb +++ b/lib/tasks/helpers/simple_interfaces.rb @@ -1,28 +1,11 @@ module SimpleInterfacesHelper - def self.interface_output_to_csv interface, output_dir - FileUtils.mkdir_p output_dir - filepath = File.join output_dir, + "#{interface.configuration_name}_#{Time.now.strftime "%y%m%d%H%M"}_out.csv" - cols = %w(line kind event message error) - if interface.reload.journal.size > 0 && interface.journal.first["row"].present? - keys = interface.journal.first["row"].map(&:first) - CSV.open(filepath, "w") do |csv| - csv << cols + keys - interface.journal.each do |j| - csv << cols.map{|c| j[c]} + j["row"].map(&:last) - end - end - puts "Task Output written in #{filepath}" - end - end - def self.run_interface_controlling_interruption interface, method, args begin interface.send(method, verbose: true) rescue Interrupt + interface.write_output_to_csv raise ensure - puts "\n\e[33m***\e[0m Done, status: " + (interface.status == "success" ? "\e[32m" : "\e[31m" ) + (interface.status || "") + "\e[0m" - interface_output_to_csv interface, args[:logs_output_dir] end end end |
