- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/summit_copy.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/ippScripts/scripts/summit_copy.pl
r23688 r27840 12 12 use Sys::Hostname; 13 13 14 use Digest::MD5::File qw( file_md5_hex ); 14 15 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 15 16 use Pod::Usage qw( pod2usage ); … … 21 22 22 23 # Parse the command-line arguments 23 my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $exp_name, $inst, $telescope, $class, $class_id, $end_stage, $workdir,24 my ( $uri, $filename, $compress, $bytes, $md5, $nebulous, $exp_name, $inst, $telescope, $class, $class_id, 24 25 $dbname, $verbose, $no_update, $no_op, $timeout, $copies ); 25 26 GetOptions( … … 35 36 'class=s' => \$class, # Class level 36 37 'class_id=s' => \$class_id, # Class identifier 37 'end_stage=s' => \$end_stage, # end of processing38 'workdir=s' => \$workdir, # workdir39 38 'dbname=s' => \$dbname, # Database name 40 39 'verbose' => \$verbose, # Print to stdout … … 62 61 my $pztool = can_run('pztool') 63 62 or (warn "Can't find pztool" and $missing_tools = 1); 63 my $neblocate = can_run('neb-locate') 64 or (warn "Can't find neb-locate" and $missing_tools = 1); 64 65 if ($missing_tools) { 65 66 warn("Can't find required tools."); 66 67 exit($PS_EXIT_CONFIG_ERROR); 67 68 } 69 70 my $ipprc = PS::IPP::Config->new(); 68 71 69 72 # dsget command … … 97 100 } 98 101 102 # 103 # Find all instances of the new file and make sure they have the 104 # same checksum and size. 105 # if so pass the results to pztool to the results in pzDownloadImfile. 106 # uncomment this to turn on 107 my ($new_bytes, $new_md5) = check_instances($filename, $nebulous, $compress); 108 99 109 # command to update database 100 110 $command = "$pztool -copydone"; … … 106 116 $command .= " -class_id $class_id"; 107 117 $command .= " -uri $filename"; 108 # $command .= " -workdir $workdir";109 118 $command .= " -hostname $host"; 110 # $command .= " -end_stage $end_stage" if defined $end_stage;111 119 $command .= " -dbname $dbname" if defined $dbname; 120 121 # XXX: TODO: see above. Don't do this until pztool and the DB have 122 # been updated 123 $command .= " -md5sum $new_md5 -bytes $new_bytes"; 112 124 113 125 # update the database … … 122 134 } else { 123 135 print "skipping command: $command\n"; 136 } 137 138 sub get_file_params 139 { 140 my $filename = shift; 141 142 my $size = -s $filename; 143 my $md5 = file_md5_hex($filename); 144 145 return ($size, $md5); 146 } 147 148 sub check_instances { 149 my $filename = shift; 150 my $nebulous = shift; 151 my $compress = shift; 152 153 my @instances; 154 if ($nebulous) { 155 my $command = "$neblocate --path --all $filename"; 156 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) 157 = run(command => $command, verbose => $verbose); 158 unless ($success) { 159 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 160 my_die("Unable to perform neb-locate: $error_code", 161 $exp_name, 162 $inst, 163 $telescope, 164 $class, 165 $class_id, 166 $uri, 167 $error_code 168 ); 169 } 170 @instances = split "\n", join "", @$stdout_buf; 171 } else { 172 if (!defined $ipprc) { 173 # we don't usually need this so defer instantaiating it 174 $ipprc = PS::IPP::Config->new(); 175 } 176 my $resolved = $ipprc->file_resolve($filename); 177 if ($resolved) { 178 $instances[0] = $resolved; 179 } 180 } 181 if (! scalar @instances) { 182 my_die("no instances", 183 $exp_name, 184 $inst, 185 $telescope, 186 $class, 187 $class_id, 188 $uri, 189 $PS_EXIT_UNKNOWN_ERROR 190 ); 191 } 192 193 my ($new_bytes, $new_md5) = get_file_params($instances[0]); 194 195 for (my $i = 1; $i < scalar @instances; $i++) { 196 my ($b, $m) = get_file_params($instances[$i]); 197 my $error = ""; 198 if ($b ne $new_bytes) { 199 $error = "size of $instances[$i] does not match $instances[0]"; 200 } elsif ($m ne $new_md5) { 201 $error = "md5sum of $instances[$i] does not match $instances[0]"; 202 } 203 if ($error) { 204 my_die($error, 205 $exp_name, 206 $inst, 207 $telescope, 208 $class, 209 $class_id, 210 $uri, 211 $PS_EXIT_DATA_ERROR 212 ); 213 } 214 } 215 216 return ($new_bytes, $new_md5); 217 124 218 } 125 219
Note:
See TracChangeset
for help on using the changeset viewer.
