mirror of https://github.com/ecmwf/eccodes.git
Scripts: cleanup
This commit is contained in:
parent
201443c6ac
commit
32c66d0832
|
@ -9,9 +9,10 @@ use DBI;
|
|||
my $basedir = dirname($0);
|
||||
|
||||
my $db="param";
|
||||
my $host="grib-param-db-test.ecmwf.int";
|
||||
my $user="ecmwf_ro";
|
||||
my $pass="ecmwf_ro";
|
||||
my $host = $ENV{'PARAM_DB_HOST'} || 'unknown';
|
||||
my $user = $ENV{'PARAM_DB_USER'} || 'unknown';
|
||||
my $pass = $ENV{'PARAM_DB_PASS'} || 'unknown';
|
||||
|
||||
my $filename; my $filebase; my $out; my $conceptDir;
|
||||
my $query; my $q; my $qh;
|
||||
|
||||
|
@ -56,7 +57,7 @@ EOF
|
|||
mkpath($filebase);
|
||||
|
||||
print TAR "grib$edition$conceptDir/$key.def\n";
|
||||
system("cp -f $filebase/$key.def $filebase/$key.def.orig");
|
||||
#system("cp -f $filebase/$key.def $filebase/$key.def.orig");
|
||||
open($out,"> $filebase/$key.def")
|
||||
or die "unable to open $filebase/$key.def";
|
||||
print $out "# Automatically generated by $0, do not edit\n";
|
||||
|
@ -99,11 +100,11 @@ sub create_def {
|
|||
if ($key =~ /units/) { $field="units.name"; }
|
||||
|
||||
my $query= <<"EOF";
|
||||
select $field,force128,edition,
|
||||
centre.abbreviation,param_id,attribute.name,attribute_value,param.name,param.shortName
|
||||
from param,grib,attribute,centre,units where param.hide_def=0 and param.id=grib.param_id
|
||||
and attribute.id=grib.attribute_id and centre.id=grib.centre and units.id=param.units_id
|
||||
order by edition,centre,param.o,param.id,grib.param_version,attribute.o;
|
||||
select $field,force128,edition,
|
||||
centre.abbreviation,param_id,attribute.name,attribute_value,param.name,param.shortName
|
||||
from param,grib,attribute,centre,units where param.hide_def=0 and param.id=grib.param_id
|
||||
and attribute.id=grib.attribute_id and centre.id=grib.centre and units.id=param.units_id
|
||||
order by edition,centre,param.o,param.id,grib.param_version,attribute.o;
|
||||
EOF
|
||||
|
||||
my $qh=$dbh->prepare($query);
|
||||
|
@ -135,8 +136,7 @@ EOF
|
|||
# or die ("unable to copy $filebase/$key.def");
|
||||
|
||||
print TAR "grib$edition$conceptDir/$key.def\n";
|
||||
system("cp -f $filebase/$key.def $filebase/$key.def.orig");
|
||||
#system("p4 edit $filebase/$key.def");
|
||||
#system("cp -f $filebase/$key.def $filebase/$key.def.orig");
|
||||
open($out,"> $filebase/$key.def")
|
||||
or die "unable to open $filebase/$key.def";
|
||||
print $out "# Automatically generated by $0, do not edit\n";
|
||||
|
@ -170,19 +170,19 @@ EOF
|
|||
}
|
||||
|
||||
sub create_paramId_def {
|
||||
my $p; my %seen;
|
||||
my $p; my %seen;
|
||||
|
||||
my $query="select edition,centre.abbreviation,param_id,attribute.name,attribute_value,param.name,param.shortName
|
||||
from param,grib,attribute,centre where param.hide_def=0 and param.id=grib.param_id
|
||||
and attribute.id=grib.attribute_id and centre.id=grib.centre
|
||||
order by edition,centre,param.o,param.id,attribute.o";
|
||||
my $query="select edition,centre.abbreviation,param_id,attribute.name,attribute_value,param.name,param.shortName
|
||||
from param,grib,attribute,centre where param.hide_def=0 and param.id=grib.param_id
|
||||
and attribute.id=grib.attribute_id and centre.id=grib.centre
|
||||
order by edition,centre,param.o,param.id,attribute.o";
|
||||
|
||||
my $qh=$dbh->prepare($query);
|
||||
$qh->execute();
|
||||
my $qh=$dbh->prepare($query);
|
||||
$qh->execute();
|
||||
|
||||
while (my ($edition,$centre,$paramId,$attribute,$value,$name,$shortName)=$qh->fetchrow_array )
|
||||
{
|
||||
if ($centre eq "all" ) { $conceptDir=""; }
|
||||
while (my ($edition,$centre,$paramId,$attribute,$value,$name,$shortName)=$qh->fetchrow_array )
|
||||
{
|
||||
if ($centre eq "all" ) { $conceptDir=""; }
|
||||
else { $conceptDir="/localConcepts/$centre"; }
|
||||
|
||||
if ($filebase ne "$basedir/grib$edition$conceptDir") {
|
||||
|
@ -191,27 +191,26 @@ sub create_paramId_def {
|
|||
close $out;
|
||||
}
|
||||
$filebase="$basedir/grib$edition$conceptDir";
|
||||
mkpath($filebase);
|
||||
mkpath($filebase);
|
||||
|
||||
copy("$filebase/paramId.def","$filebase/paramId.def.bkp")
|
||||
or die ("unable to copy $filebase/paramId.def");
|
||||
system("p4 edit $filebase/paramId.def");
|
||||
or die ("unable to copy $filebase/paramId.def");
|
||||
open($out,"> $filebase/paramId.def")
|
||||
or die "unable to open $filebase/paramId.def";
|
||||
print $out "# Automatically generated by $0, do not edit\n";
|
||||
$p=();
|
||||
}
|
||||
if ($p ne $paramId || exists($seen{$attribute}) ) {
|
||||
if ($p) { print $out "\t}\n"; }
|
||||
print $out "#$name\n" ;
|
||||
print $out "\'".$paramId."\' = {\n" ;
|
||||
$p=$paramId;
|
||||
%seen=();
|
||||
}
|
||||
$seen{$attribute}=1;
|
||||
print "$edition,$centre,$shortName,$paramId,$name,$attribute,$value\n";
|
||||
print $out "\t $attribute = $value ;\n" ;
|
||||
}
|
||||
if ($p ne $paramId || exists($seen{$attribute}) ) {
|
||||
if ($p) { print $out "\t}\n"; }
|
||||
print $out "#$name\n" ;
|
||||
print $out "\'".$paramId."\' = {\n" ;
|
||||
$p=$paramId;
|
||||
%seen=();
|
||||
}
|
||||
$seen{$attribute}=1;
|
||||
print "$edition,$centre,$shortName,$paramId,$name,$attribute,$value\n";
|
||||
print $out "\t $attribute = $value ;\n" ;
|
||||
}
|
||||
if ($filebase) {
|
||||
print $out "}\n";
|
||||
close $out;
|
||||
|
@ -219,14 +218,14 @@ sub create_paramId_def {
|
|||
}
|
||||
|
||||
sub create_def_old {
|
||||
my ($key,$query)=@_;
|
||||
my ($key,$query)=@_;
|
||||
|
||||
my $qh=$dbh->prepare($query);
|
||||
$qh->execute();
|
||||
my $qh=$dbh->prepare($query);
|
||||
$qh->execute();
|
||||
|
||||
while (my ($edition,$centre,$paramId,$value)=$qh->fetchrow_array )
|
||||
{
|
||||
if ($centre eq "all" ) { $conceptDir=""; }
|
||||
while (my ($edition,$centre,$paramId,$value)=$qh->fetchrow_array )
|
||||
{
|
||||
if ($centre eq "all" ) { $conceptDir=""; }
|
||||
else { $conceptDir="/localConcepts/$centre"; }
|
||||
|
||||
if ($filebase ne "$basedir/grib$edition$conceptDir") {
|
||||
|
@ -234,17 +233,16 @@ sub create_def_old {
|
|||
close $out;
|
||||
}
|
||||
$filebase="$basedir/grib$edition$conceptDir";
|
||||
mkpath($filebase);
|
||||
mkpath($filebase);
|
||||
|
||||
copy("$filebase/$key.def","$filebase/$key.def.bkp")
|
||||
or die ("unable to copy $filebase/$key.def");
|
||||
system("p4 edit $filebase/$key.def");
|
||||
or die ("unable to copy $filebase/$key.def");
|
||||
open($out,"> $filebase/$key.def")
|
||||
or die "unable to open $filebase/$key.def";
|
||||
print $out "# Automatically generated by $0, do not edit\n";
|
||||
}
|
||||
print $out "\'$value\' \t= { paramId=$paramId; }\n";
|
||||
}
|
||||
print $out "\'$value\' \t= { paramId=$paramId; }\n";
|
||||
}
|
||||
if ($filebase) {
|
||||
close $out;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue