| author | Vincent Tondellier <tonton+hg@team1664.org> |
| Fri, 08 Aug 2014 00:00:49 +0200 | |
| changeset 37 | 013953be0f3b |
| parent 31 | f77c6719c05c |
| child 43 | 6070307efd38 |
| permissions | -rwxr-xr-x |
|
31
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
1 |
#!/usr/bin/env perl |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
2 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
3 |
# This program is free software: you can redistribute it and/or modify |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
4 |
# it under the terms of the GNU General Public License as published by |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
5 |
# the Free Software Foundation, either version 3 of the License, or |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
6 |
# (at your option) any later version. |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
7 |
# |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
8 |
# This program is distributed in the hope that it will be useful, |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
11 |
# GNU General Public License for more details. |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
12 |
# |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
13 |
# You should have received a copy of the GNU General Public License |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
15 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
16 |
use Mojo::Base -strict; |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
17 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
18 |
use lib 'lib'; |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
19 |
use CrashTest::Storage::Sql; |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
20 |
use Mojo::JSON; |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
21 |
use Mojo::Util qw(decode slurp); |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
22 |
use File::Basename; |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
23 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
24 |
sub load_config {
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
25 |
my ($file) = @_; |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
26 |
my $code = decode('UTF-8', slurp $file);
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
27 |
return eval($code); |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
28 |
} |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
29 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
30 |
my $config = load_config("CrashTest.conf");
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
31 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
32 |
eval "require $config->{Storage}->{Type}";
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
33 |
my $storage = $config->{Storage}->{Type}->new($config->{Storage});
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
34 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
35 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
36 |
foreach my $arg (@ARGV) {
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
37 |
my $json = Mojo::JSON->new(); |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
38 |
my $pjson = $json->decode(slurp $arg); |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
39 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
40 |
my($filename, $dirs, $suffix) = fileparse($arg, qr/\.[^.]*/); |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
41 |
|
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
42 |
my $uuid = $filename; |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
43 |
$storage->_db_insert_processed_data($uuid, $pjson); |
|
f77c6719c05c
Add migration script
Vincent Tondellier <tonton+hg@team1664.org>
parents:
diff
changeset
|
44 |
} |