IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 14, 2023, 12:02:11 PM (3 years ago)
Author:
eugene
Message:

new instances from fix_chip_locations need to go to unique files by chip; get_md5s_instances needs to load the additional instance lists

File:
1 edited

Legend:

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

    r42444 r42451  
    1313# USAGE: get_md5s_instances.pl --hostname (hostname) --input (file) --stage (0,1,etc)
    1414
    15 my ($myhost, $input, $stage) = &parse_cmdopts;
     15my $input;
     16my ($myhost, $dateword, $topdir, $stage) = &parse_cmdopts;
    1617
    1718# check that we are running this script on 'myhost'
     
    2021
    2122# read the list of instances:
    22 my ($ins_list_r, $dst_list_r, $md5_list_r) = &load_instance_list ($input);
     23my ($ins_list_r, $dst_list_r, $md5_list_r) = &load_instance_list ();
    2324
    24 my $output = $input;
    25 $output =~ s/inst.$stage/md5s/;
     25my $output = "$topdir/$dateword/$myhost.md5s.txt";
    2626
    27 if ($output eq $input) { die "output file ($output) matches input file ($input)\n"; }
    28 
    29 # read in both instance
     27# read in existing md5s
    3028my $out_hash_r;
    3129if (-e $output) {
     
    6058    }
    6159
    62     my $line;
    63     if (0) {
    64         $line = "fakevalue $filename"; # XXX TEST: disable calculation:
    65     } else {
    66         $line = `md5sum $filename`;
    67     }
     60    my $line = `md5sum $filename`;
    6861
    6962    my ($md5sum, $rawfile) = split (" ", $line);
     
    7366exit 0;
    7467
     68# use global $topdir, $dateword, $myhost, $stage
     69sub load_instance_list {
     70    my (@ins_list, @dst_list, @md5_list);
     71
     72    # load the master list
     73    my $input = "$topdir/$dateword/$myhost.inst.$stage.txt";
     74    &load_instance_list_onefile ($input, \@ins_list, \@dst_list, \@md5_list);
     75
     76    # there may be additional instances in files with names like HOSTNAME.XYnn.inst.STAGE
     77    my @instlist = glob ("$topdir/$dateword/$myhost.XY??.inst.$stage.txt");
     78    foreach my $infile  (@instlist) {
     79        &load_instance_list_onefile ($infile, \@ins_list, \@dst_list, \@md5_list);
     80    }
     81    return (\@ins_list, \@dst_list, \@md5_list);
     82}
     83
    7584# read the instance info
    76 sub load_instance_list {
     85sub load_instance_list_onefile {
    7786    my $infile = $_[0];
    78 
    79     my (@ins_list, @dst_list, @md5_list);
     87    my $ins_list_r = $_[1]; # reference to the instance list array
     88    my $dst_list_r = $_[2]; # reference to the instance list array
     89    my $md5_list_r = $_[3]; # reference to the instance list array
    8090
    8191    open(FILE,$infile) or die "cannot open file $infile\n";
     
    8999
    90100        if (@words != 3) { die "error in input $infile : $line\n"; }
    91         push (@ins_list, $words[0]);
    92         push (@dst_list, $words[1]);
    93         push (@md5_list, $words[2]);
     101        push (@$ins_list_r, $words[0]);
     102        push (@$dst_list_r, $words[1]);
     103        push (@$md5_list_r, $words[2]);
    94104    }
    95105    close (FILE);
    96 
    97     return (\@ins_list, \@dst_list, \@md5_list);
    98106}
    99107
     
    123131sub parse_cmdopts {
    124132
    125     my ($myhost, $input, $stage);
    126     GetOptions( 'hostname=s' => \$myhost, 'input=s' => \$input, 'stage=s' => \$stage) || pod2usage(2);
     133    my ($myhost, $topdir, $dateobs, $stage);
     134    GetOptions( 'hostname=s' => \$myhost, 'topdir=s' => \$topdir, 'dateobs=s' => \$dateobs, 'stage=s' => \$stage) || pod2usage(2);
    127135   
    128     pod2usage( -msg => "Provide the input list with --input", -exitval => 2) unless defined $input;
     136    pod2usage( -msg => "Cannot determine target date, use --dateobs YYYYMMDD", -exitval => 2) unless defined $dateobs;
     137#   pod2usage( -msg => "Provide the input list with --input", -exitval => 2) unless defined $input;
    129138    pod2usage( -msg => "Define the host machine with --hostname", -exitval => 2) unless defined $myhost;
    130139    pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage;
     140    pod2usage( -msg => "Specify the top-level output directory with --topdir", -exitval => 2) unless defined $topdir;
    131141   
    132142    # check that stage is an integer
     
    134144    unless ($stage >= 0) { die "stage must be a non-negative integer\n"; }
    135145   
    136     return ($myhost, $input, $stage);
     146    return ($myhost, $dateobs, $topdir, $stage);
    137147}
    138148
Note: See TracChangeset for help on using the changeset viewer.