- Timestamp:
- Feb 8, 2010, 2:47:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/ippScripts/scripts/magic_process.pl
r25934 r26812 31 31 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1); 32 32 my $detectstreaks = can_run('DetectStreaks') or (warn "Can't find DetectStreaks" and $missing_tools = 1); 33 my $VerifyStreaks = can_run('VerifyStreaks') or (warn "Can't find VerifyStreaks, will not produce png images"); 33 34 if ($missing_tools) { 34 35 warn("Can't find required tools."); … … 37 38 38 39 # Parse the command-line arguments 39 my ($magic_id, $node, $camera, $dbname, $ outroot, $save_temps, $verbose, $no_update, $no_op, $logfile);40 my ($magic_id, $node, $camera, $dbname, $baseroot, $save_temps, $verbose, $no_update, $no_op, $logfile); 40 41 41 42 GetOptions( … … 44 45 'camera=s' => \$camera, # Camera name 45 46 'dbname=s' => \$dbname, # Database name 46 ' outroot=s' => \$outroot,# Output root name47 'baseroot=s' => \$baseroot, # Output root name 47 48 'save-temps' => \$save_temps, # Save temporary files? 48 49 'verbose' => \$verbose, # Print stuff? … … 53 54 54 55 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 55 pod2usage( -msg => "Required options: --magic_id --camera --node -- outroot",56 pod2usage( -msg => "Required options: --magic_id --camera --node --baseroot", 56 57 -exitval => 3) unless 57 58 defined $magic_id and 58 59 defined $node and 59 60 defined $camera and 60 defined $ outroot;61 defined $baseroot; 61 62 62 63 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $node, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 63 64 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $node, $PS_EXIT_SYS_ERROR ) if $logfile; 64 65 65 # DetectStreaks doesn't know about nebulous. It expects to be able to append strings to outroot 66 # to form valid file names. 67 # So forbid nebulous path in outroot. We could relax this by change DetectStreaks to take all 68 # of the file names as arguments or by teaching it about Nebulous 69 if ($outroot =~ 'neb:/') { 66 # DetectStreaks doesn't know about nebulous. It expects to be able to 67 # append strings to baseroot to form valid file names. So forbid 68 # nebulous path in baseroot. We could relax this by change 69 # DetectStreaks to take all of the file names as arguments or by 70 # teaching it about Nebulous 71 if ($baseroot =~ 'neb:/') { 70 72 &my_die("DetectStreaks does not support nebulous paths in outroot", $magic_id, $node, $PS_EXIT_CONFIG_ERROR); 71 73 } 72 74 75 # most filenames are of the form $baseroot.$node.*, but VerifyStreaks 76 # needs access to $baseroot.*, so we construct $outroot = 77 # $baseroot.$node in here 78 73 79 # resolve any path:// or file:// in outroot 74 $outroot = $ipprc->file_resolve($outroot); 80 $baseroot = $ipprc->file_resolve($baseroot); 81 my $outroot = "$baseroot.$node"; 75 82 76 83 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 255 262 } 256 263 264 &run_verifystreaks($baseroot); 265 257 266 my $command = "$magictool -addmask"; 258 267 $command .= " -magic_id $magic_id"; … … 275 284 } 276 285 277 278 279 286 ### Pau. 287 288 sub run_verifystreaks { 289 290 my $baseroot = shift; 291 292 unless ($VerifyStreaks) { 293 print STDERR "skipping VerifyStreaks\n"; 294 return 1; 295 } 296 297 # VerifyStreaks --out $outdir --clusters $outdir/clusters.list $rootname.root.streakMap 298 299 my $outdir = "$baseroot.verify"; 300 301 my($status) = system ("mkdir -p $outdir"); 302 if ($status) { 303 print STDERR "failed to create output directory $outdir\n"; 304 return 1; 305 } 306 307 my @files = <$baseroot.*.clusters>; 308 unless (OPEN (FILE, ">$outdir/clusters.list")) { 309 print "failed to create cluster file $outdir/clusters.list\n"; 310 return 1; 311 } 312 foreach my $file (@files) { 313 print FILE "$file\n"; 314 } 315 close (FILE); 316 if ($status) { 317 print "failed to create cluster file $outdir/clusters.list\n"; 318 return 1; 319 } 320 321 my $command = "$VerifyStreaks --out $outdir --clusters $outdir/clusters.list $baseroot.root.streakMap"; 322 323 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 324 run(command => $command, verbose => $verbose); 325 unless ($success) { 326 print "failed to run VerifyStreaks:\n stderr: $stderr_buff\n stdout: $stdout_buff"; 327 return 1; 328 } 329 330 return 0; 331 } 280 332 281 333 sub open_list_file {
Note:
See TracChangeset
for help on using the changeset viewer.
