- Timestamp:
- Apr 6, 2023, 6:00:06 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/eam/rawfix.20230221/src/get_md5s_instances.pl
r42441 r42444 11 11 use Getopt::Long qw( GetOptions :config auto_help auto_version ); 12 12 13 # USAGE: get_md5s_instances.pl --hostname (hostname) --input (file) --stage ( v0,v1,etc)13 # USAGE: get_md5s_instances.pl --hostname (hostname) --input (file) --stage (0,1,etc) 14 14 15 15 my ($myhost, $input, $stage) = &parse_cmdopts; … … 26 26 27 27 if ($output eq $input) { die "output file ($output) matches input file ($input)\n"; } 28 29 # read in both instance 30 my $out_hash_r; 28 31 if (-e $output) { 29 # check that all instances are in the output file? 30 print "$output exists, skipping\n"; 31 exit 0; 32 $out_hash_r = &load_output_list ($output); 32 33 } 33 34 34 open (OUTFILE, "> $output");35 open (OUTFILE, ">>$output"); 35 36 36 37 # foreach my $instance (@$ins_list_r) { … … 41 42 my $md5sum_tru = $md5_list_r->[$i]; 42 43 44 # if the instance is already in the output file, skip it 45 if (defined $out_hash_r) { 46 my $name = $out_hash_r->{$instance}; 47 if (defined $name) { 48 print STDERR "skipping $instance (already in output)\n"; 49 next; 50 } 51 } 52 43 53 my $filename = $instance; 44 54 $filename =~ s|file://||; 45 55 46 56 # check for the existence of the file first: 47 57 unless (-e $filename) { … … 63 73 exit 0; 64 74 65 # read the list of chip_ids:75 # read the instance info 66 76 sub load_instance_list { 67 77 my $infile = $_[0]; … … 88 98 } 89 99 100 # read the instance list in the output file 101 sub load_output_list { 102 my $infile = $_[0]; 103 104 my (%out_hash); 105 106 open(FILE,$infile) or die "cannot open file $infile\n"; 107 108 my @lines = <FILE>; 109 110 foreach my $line (@lines) { 111 chomp $line; 112 if ($line =~ /^\s*#/) { next; } # skip lines with leading # 113 my @words = split (/\s+/,$line); 114 115 if (@words != 4) { die "error in input $infile : $line\n"; } 116 $out_hash{$words[0]} = 1; 117 } 118 close (FILE); 119 120 return (\%out_hash); 121 } 122 90 123 sub parse_cmdopts { 91 124 … … 95 128 pod2usage( -msg => "Provide the input list with --input", -exitval => 2) unless defined $input; 96 129 pod2usage( -msg => "Define the host machine with --hostname", -exitval => 2) unless defined $myhost; 97 pod2usage( -msg => "Define the stage (v0, v1, etc) with --stage", -exitval => 2) unless defined $stage; 130 pod2usage( -msg => "Define the stage (0, 1, etc) with --stage", -exitval => 2) unless defined $stage; 131 132 # check that stage is an integer 133 unless (is_integer ($stage)) { die "stage must be a non-negative integer\n"; } 134 unless ($stage >= 0) { die "stage must be a non-negative integer\n"; } 98 135 99 136 return ($myhost, $input, $stage); … … 106 143 return $status; 107 144 } 145 146 sub is_integer { 147 defined $_[0] && $_[0] =~ /^[+-]?\d+$/; 148 } 149
Note:
See TracChangeset
for help on using the changeset viewer.
