Changeset 30049 for trunk/ippScripts/scripts/register_imfile.pl
- Timestamp:
- Dec 15, 2010, 1:29:28 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/register_imfile.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/czw_branch/20101203 (added) merged: 29907-29909,29965,29982,30014,30017-30018,30047-30048
- Property svn:mergeinfo changed
-
trunk/ippScripts/scripts/register_imfile.pl
r27891 r30049 19 19 use File::Basename qw( basename); 20 20 use IPC::Run; 21 use IPC::Cmd 0.36 qw( can_run );21 use IPC::Cmd 0.36 qw( can_run run ); 22 22 use PS::IPP::Config 1.01 qw( :standard ); 23 use PS::IPP::Metadata::List qw( parse_md_list ); 23 24 use PS::IPP::Metadata::Config; 24 25 use Math::Trig; … … 35 36 my $ppStatsFromMetadata = can_run( 'ppStatsFromMetadata' ) or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 36 37 my $ppConfigDump = can_run( 'ppConfigDump' ) or (warn "Can't find ppConfigDump" and $missing_tools = 1); 38 my $ippApplyBurntoolSingle = can_run( 'ipp_apply_burntool_single.pl' ) or (warn "Can't find ipp_apply_burntool_single" and $missing_tools = 1); 37 39 38 40 my ($cache, $exp_id, $tmp_class_id, $tmp_exp_name, $uri, $bytes, $md5sum, $dbname, $verbose, $no_update, $no_op, $logfile); … … 82 84 83 85 my $cmdflags; 86 my $burntoolStateGood; 84 87 # Run ppStats on the input file 85 88 { … … 114 117 my $burntoolState = 0; 115 118 my $isGPC1 = 0; 116 my$burntoolStateGood = 0;119 $burntoolStateGood = 0; 117 120 foreach my $line (split /\n/, $out1) { 118 121 if ($line =~ /FPA.BURNTOOL.APPLIED/) { … … 174 177 $command .= " -hostname $host" if defined $host; 175 178 $command .= " -dbname $dbname" if defined $dbname; 176 $command .= " -data_state full";179 $command .= " -data_state check_burntool"; 177 180 $command .= " $cmdflags"; 178 181 182 print "$command\n"; 179 183 # determine solar-system parameters 180 184 my $longitude = &value_for_flag($cmdflags, 0.0, "-longitude"); … … 206 210 } 207 211 } 212 213 # This might have a race condition 214 # $date_end = $dateobs; 215 # $date_start = $dateobs - 30 minutes ? dateobs_UTC_midnight? 216 # lock file? 217 # if exp_type = DARK and date > MIDNIGHT HST { wait } 218 # system("ipp_apply_burntool.pl --class_id $class_id --dateobs_begin $date_start --dateobs_end $date_end --dbname gpc1 --logfile /data/$host.0/burntool_logs/$class_id.$start_date.log"); 208 219 209 220 $now_time = localtime(); … … 222 233 print "skipping command: $command\n"; 223 234 } 235 236 # We now have an imfile in the database, check if we can burntool it. If not, continue on. 237 238 { 239 my $mdcParser = PS::IPP::Metadata::Config->new; 240 241 my $class_id = &value_for_flag($cmdflags, 0.0, "-class_id"); 242 my $check_date = &value_for_flag($cmdflags, 0.0, "-dateobs"); 243 $check_date =~ s/T.*$//; 244 my $exp_name = $tmp_exp_name; 245 246 247 my $bt_check_command = "$regtool -checkburntoolimfile "; 248 $bt_check_command .= " -class_id $class_id "; 249 $bt_check_command .= " -date $check_date "; 250 $bt_check_command .= " -valid_burntool $burntoolStateGood "; 251 $bt_check_command .= " -exp_name $exp_name "; 252 $bt_check_command .= " -dbname $dbname" if defined $dbname; 253 254 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 255 run ( command => $bt_check_command, verbose => $verbose); 256 unless ($success) { 257 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 258 &my_die("Unable to perform regtool: $error_code", 259 $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR); 260 } 261 262 my @whole = split /\n/, (join "", @$stdout_buf); 263 my @single = (); 264 my $exposures; 265 while ( scalar @whole > 0 ) { 266 my $value = shift @whole; 267 push @single, $value; 268 if ($value =~ /^\s*END\s*$/) { 269 push @single, "\n"; 270 271 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ); 272 &my_die("Unable to parse output from regtool", 273 $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR) unless 274 defined $list; 275 push @{ $exposures }, @$list; 276 @single = (); 277 } 278 } 279 280 # We only care about the final entry, as that contains the exposure we are. 281 282 my $regtool_update = "$regtool -updateprocessedimfile "; 283 $regtool_update .= "-dbname $dbname " if defined $dbname; 284 $regtool_update .= "-exp_id $exp_id -class_id $class_id "; 285 286 my $burntool_data = pop(@{ $exposures }); 287 if ($burntool_data->{burnable} == 0) { 288 $regtool_update .= " -burntool_state 0 -set_state pending_burntool "; 289 } 290 else { 291 my $apply_command = "$ippApplyBurntoolSingle --dbname $dbname "; 292 $apply_command .= " --class_id $class_id --exp_id $exp_id "; 293 $apply_command .= " --this_uri $burntool_data->{uri} "; 294 $apply_command .= " --previous_uri $burntool_data->{previous_uri} " if defined $burntool_data->{previous_uri}; 295 $apply_command .= " --imfile_state $burntool_data->{imfile_state} "; 296 $apply_command .= " --verbose " if $verbose; 297 print "$apply_command\n"; 298 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 299 IPC::Cmd::run(command => $apply_command, verbose => $verbose); 300 unless ($success) { 301 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 302 warn ("Unable to perform ipp_apply_burntool_single.pl: $error_code"); 303 exit($error_code); 304 } 305 } 306 307 unless ($no_update) { 308 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 309 IPC::Cmd::run(command => $regtool_update, verbose => $verbose); 310 unless ($success) { 311 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 312 warn ("Unable to perform regtool -addprocessedimfile: $error_code"); 313 exit($error_code); 314 } 315 } else { 316 print "skipping command: $command\n"; 317 } 318 319 } 320 321 224 322 225 323 $now_time = localtime();
Note:
See TracChangeset
for help on using the changeset viewer.
