diff -r f65708dc1be1 -r f77c6719c05c bin/fs_to_db.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/fs_to_db.pl Mon Aug 04 14:51:37 2014 +0200 @@ -0,0 +1,44 @@ +#!/usr/bin/env perl + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use Mojo::Base -strict; + +use lib 'lib'; +use CrashTest::Storage::Sql; +use Mojo::JSON; +use Mojo::Util qw(decode slurp); +use File::Basename; + +sub load_config { + my ($file) = @_; + my $code = decode('UTF-8', slurp $file); + return eval($code); +} + +my $config = load_config("CrashTest.conf"); + +eval "require $config->{Storage}->{Type}"; +my $storage = $config->{Storage}->{Type}->new($config->{Storage}); + + +foreach my $arg (@ARGV) { + my $json = Mojo::JSON->new(); + my $pjson = $json->decode(slurp $arg); + + my($filename, $dirs, $suffix) = fileparse($arg, qr/\.[^.]*/); + + my $uuid = $filename; + $storage->_db_insert_processed_data($uuid, $pjson); +}