- Timestamp:
- Apr 7, 2023, 4:50:38 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rawfix.20230221/src/fix_chip_locations.pl
r42444 r42445 19 19 20 20 my ($fulldate, $dateword, $chiplist, $stage, $topdir) = &parse_cmdopts; 21 my ($neb_dbh ) = &parse_db_config ("$topdir/nebulous.config");21 my ($neb_dbh, $raw_dbh) = &parse_db_config ("$topdir/nebulous.config"); 22 22 23 23 # read the list of chip_ids: … … 68 68 } 69 69 70 my $Nchip = 0; 71 70 72 foreach my $chip_id (@chip_ids) { 71 73 … … 96 98 if ($failchips{$ext_id}) { $haveMD5 = 1; } 97 99 100 $Nchip ++; 98 101 99 102 # nothing to be done, or need be done for these: … … 143 146 close (OUTFILE); 144 147 } 145 $Ndups++;148 if ($goodMD5) { $Ndups++; } else { $Nfail ++; } 146 149 next; 147 150 } … … 160 163 close (OUTFILE); 161 164 } 162 $Nxbck++;165 if ($goodMD5) { $Nxbck++; } else { $Nfail ++; } 163 166 next; 164 167 } … … 191 194 192 195 # 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 ++; } 196 201 } 197 202 } … … 199 204 } 200 205 206 print "Nchip: $Nchip\n"; 201 207 print "Ngood: $Ngood\n"; 202 208 print "Ngone: $Ngone\n"; … … 209 215 print "Ncul2: $Ncul2\n"; 210 216 print "Ncul3: $Ncul3\n"; 217 print "Nfail: $Nfail\n"; 218 219 my $Ntotal = $Ngood + $Ngone + $Ndead + $Nsing + $Ndups + $Nsbck + $Nxbck + $Ncul1 + $Ncul2 + $Ncul3 + $Nfail; 220 if ($Ntotal != $Nchip) { die "ERROR: inconsistent count of chips\n"; } 221 222 # update the stats in the database 223 my $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 238 my $query = $raw_dbh->prepare($sql_update_stats); 239 $query->execute () or die "invalid response from RAW database\n"; 211 240 212 241 exit 0; … … 398 427 399 428 my ( $nebdb_name, $nebdb_host, $nebdb_port, $nebdb_pass, $nebdb_user ); 429 my ( $rawdb_name, $rawdb_host, $rawdb_port, $rawdb_pass, $rawdb_user ); 400 430 401 431 if (-e $conffile) { … … 409 439 if ($_ =~ /NEB_PASS /) { $nebdb_pass = (split /\s+/,$_)[2]; } 410 440 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]; } 411 447 } 412 448 close(IN); 413 449 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"; 414 451 } 415 452 … … 420 457 pod2usage( -msg => "Cannot configure nebulous database (dbpass)", -exitval => 2) unless defined $nebdb_pass; 421 458 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 422 465 my $nebdb_dsn = "DBI:mysql:database=$nebdb_name:host=$nebdb_host"; 423 466 if ($nebdb_port ne "NONE") { $nebdb_dsn .= ":port=$nebdb_port"; } 424 467 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"; 425 468 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); 427 474 } 428 475
Note:
See TracChangeset
for help on using the changeset viewer.
