IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 7, 2023, 4:50:38 PM (3 years ago)
Author:
eugene
Message:

rework to use a stage/iteration tracked by the rawfix database

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl

    r42444 r42445  
    1919
    2020my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts;
    21 my ($neb_dbh) = &parse_db_config ("$topdir/nebulous.config");
     21my ($neb_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config");
    2222
    2323# read the list of chip_ids:
     
    6868}
    6969
     70my $Nchip = 0;
     71
    7072foreach my $chip_id (@chip_ids) {
    7173
     
    9698        if ($failchips{$ext_id}) { $haveMD5 = 1; }
    9799
     100        $Nchip ++;
    98101
    99102        # nothing to be done, or need be done for these:
     
    143146                close (OUTFILE);
    144147            }
    145             $Ndups++;
     148            if ($goodMD5) { $Ndups++; } else { $Nfail ++; }
    146149            next;
    147150        }
     
    160163                close (OUTFILE);
    161164            }
    162             $Nxbck++;
     165            if ($goodMD5) { $Nxbck++; } else { $Nfail ++; }
    163166            next;
    164167        }
     
    191194
    192195            # these are done in stage 3:
    193             if ($state eq "CUL1:") { $Ncul1++; next; }
    194             if ($state eq "CUL2:") { $Ncul2++; next; }
    195             if ($state eq "CUL3:") { $Ncul3++; next; }
     196            if ($goodMD5) {
     197                if ($state eq "CUL1:") { $Ncul1++; next; }
     198                if ($state eq "CUL2:") { $Ncul2++; next; }
     199                if ($state eq "CUL3:") { $Ncul3++; next; }
     200            } else { $Nfail ++; }
    196201        }
    197202    }
     
    199204}
    200205
     206print "Nchip: $Nchip\n";
    201207print "Ngood: $Ngood\n";
    202208print "Ngone: $Ngone\n";
     
    209215print "Ncul2: $Ncul2\n";
    210216print "Ncul3: $Ncul3\n";
     217print "Nfail: $Nfail\n";
     218
     219my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail;
     220if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; }
     221
     222# update the stats in the database
     223my $sql_update_stats = "UPDATE nights set";
     224$sql_update_stats .= "  Nchip = $Nchip";
     225$sql_update_stats .= ", Ngood = $Ngood";
     226$sql_update_stats .= ", Ndead = $Ndead";
     227$sql_update_stats .= ", Ngone = $Ngone";
     228$sql_update_stats .= ", Nsing = $Nsing";
     229$sql_update_stats .= ", Ndups = $Ndups";
     230$sql_update_stats .= ", Nsbck = $Nsbck";
     231$sql_update_stats .= ", Nxbck = $Nxbck";
     232$sql_update_stats .= ", Ncul1 = $Ncul1";
     233$sql_update_stats .= ", Ncul2 = $Ncul2";
     234$sql_update_stats .= ", Ncul3 = $Ncul3";
     235$sql_update_stats .= ", Nfail = $Nfail";
     236$sql_update_stats .= " WHERE dateobs = $dateword";
     237
     238my $query = $raw_dbh->prepare($sql_update_stats);
     239$query->execute () or die "invalid response from RAW database\n";
    211240
    212241exit 0;
     
    398427
    399428    my ( $nebdb_name, $nebdb_host, $nebdb_port, $nebdb_pass, $nebdb_user );
     429    my ( $rawdb_name, $rawdb_host, $rawdb_port, $rawdb_pass, $rawdb_user );
    400430
    401431    if (-e $conffile) {
     
    409439            if ($_ =~ /NEB_PASS /)  { $nebdb_pass = (split /\s+/,$_)[2]; }
    410440            if ($_ =~ /NEB_PORT /)  { $nebdb_port = (split /\s+/,$_)[2]; }
     441
     442            if ($_ =~ /RAW_NAME /)  { $rawdb_name = (split /\s+/,$_)[2]; }
     443            if ($_ =~ /RAW_HOST /)  { $rawdb_host = (split /\s+/,$_)[2]; }
     444            if ($_ =~ /RAW_USER /)  { $rawdb_user = (split /\s+/,$_)[2]; }
     445            if ($_ =~ /RAW_PASS /)  { $rawdb_pass = (split /\s+/,$_)[2]; }
     446            if ($_ =~ /RAW_PORT /)  { $rawdb_port = (split /\s+/,$_)[2]; }
    411447        }
    412448        close(IN);
    413449        print STDERR  "nebulous config: $nebdb_name $nebdb_host $nebdb_port $nebdb_user $nebdb_pass\n";
     450        print STDERR  "raw  dbh config: $rawdb_name $rawdb_host $rawdb_port $rawdb_user $rawdb_pass\n";
    414451    }
    415452
     
    420457    pod2usage( -msg => "Cannot configure nebulous database (dbpass)", -exitval => 2) unless defined $nebdb_pass;
    421458
     459    pod2usage( -msg => "Cannot configure raw database (dbname)", -exitval => 2) unless defined $rawdb_name;
     460    pod2usage( -msg => "Cannot configure raw database (dbhost)", -exitval => 2) unless defined $rawdb_host;
     461    pod2usage( -msg => "Cannot configure raw database (dbuser)", -exitval => 2) unless defined $rawdb_user;
     462    pod2usage( -msg => "Cannot configure raw database (dbport)", -exitval => 2) unless defined $rawdb_port;
     463    pod2usage( -msg => "Cannot configure raw database (dbpass)", -exitval => 2) unless defined $rawdb_pass;
     464
    422465    my $nebdb_dsn = "DBI:mysql:database=$nebdb_name:host=$nebdb_host";
    423466    if ($nebdb_port ne "NONE") { $nebdb_dsn .= ":port=$nebdb_port"; }
    424467    my $neb_dbh = DBI->connect($nebdb_dsn, $nebdb_user, $nebdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
    425468
    426     return ($neb_dbh);
     469    my $rawdb_dsn = "DBI:mysql:database=$rawdb_name:host=$rawdb_host";
     470    if ($rawdb_port ne "NONE") { $rawdb_dsn .= ":port=$rawdb_port"; }
     471    my $raw_dbh = DBI->connect($rawdb_dsn, $rawdb_user, $rawdb_pass, { RaiseError => 1, AutoCommit => 1} ) or die "Unable to connect to database $DBI::errstr\n";
     472
     473    return ($neb_dbh, $raw_dbh);
    427474}
    428475
Note: See TracChangeset for help on using the changeset viewer.