aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Peignier2018-03-06 00:24:16 +0100
committerAlban Peignier2018-03-06 00:24:16 +0100
commit06d2fdab5b338eb41f1e1b4d38ecebb0fb8dbbdf (patch)
tree82fb13b53c97c91d525ee5e0810821a60bd812b4
parent75f50a80a458b1de6d211ee6a98587f1262bc1bf (diff)
downloadchouette-core-06d2fdab5b338eb41f1e1b4d38ecebb0fb8dbbdf.tar.bz2
Fixes logs_output_dir in imports tasks and into SimpleImporter#dump_csv_from_context. Refs #5924
-rw-r--r--app/models/simple_importer.rb3
-rw-r--r--lib/tasks/imports.rake6
2 files changed, 5 insertions, 4 deletions
diff --git a/app/models/simple_importer.rb b/app/models/simple_importer.rb
index e23b3e524..6f0b8d7a8 100644
--- a/app/models/simple_importer.rb
+++ b/app/models/simple_importer.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
class SimpleImporter < SimpleInterface
def resolve col_name, value, &block
val = block.call(value)
@@ -40,7 +41,7 @@ class SimpleImporter < SimpleInterface
end
def dump_csv_from_context
- dir = context[:output_dir] || "log/importers"
+ dir = context[:logs_output_dir] || "log/importers"
filepath = File.join dir, "#{self.configuration_name}_#{Time.now.strftime "%y%m%d%H%M"}.csv"
# for some reason, context[:csv].to_csv does not work
CSV.open(filepath, 'w') do |csv|
diff --git a/lib/tasks/imports.rake b/lib/tasks/imports.rake
index cd9217e5a..7162f2ada 100644
--- a/lib/tasks/imports.rake
+++ b/lib/tasks/imports.rake
@@ -31,7 +31,7 @@ namespace :import do
end
desc "import the given file with the corresponding importer in the given StopAreaReferential"
- task :import_in_stop_area_referential, [:referential_id, :configuration_name, :filepath] => :environment do |t, args|
+ task :import_in_stop_area_referential, [:referential_id, :configuration_name, :filepath, :logs_output_dir] => :environment do |t, args|
args.with_defaults(logs_output_dir: "./log/importers/")
FileUtils.mkdir_p args[:logs_output_dir]
@@ -46,7 +46,7 @@ namespace :import do
end
desc "import the given routes files"
- task :import_routes, [:referential_id, :configuration_name, :mapping_filepath, :filepath] => :environment do |t, args|
+ task :import_routes, [:referential_id, :configuration_name, :mapping_filepath, :filepath, :logs_output_dir] => :environment do |t, args|
args.with_defaults(logs_output_dir: "./log/importers/")
FileUtils.mkdir_p args[:logs_output_dir]
@@ -56,7 +56,7 @@ namespace :import do
importer = SimpleImporter.create configuration_name: args[:configuration_name], filepath: args[:filepath]
importer.configure do |config|
config.add_value :stop_area_referential, referential
- config.context = {stop_area_referential: stop_area_referential, mapping_filepath: args[:mapping_filepath], logs_output_dir: args[:logs_output_dir]}
+ config.context = {stop_area_referential: stop_area_referential, line_referential: line_referential, mapping_filepath: args[:mapping_filepath], logs_output_dir: args[:logs_output_dir]}
end
SimpleInterfacesHelper.run_interface_controlling_interruption importer, :import, args