Changeset 32507
- Timestamp:
- Oct 6, 2011, 3:17:52 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/videophot_process.pl (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/videophot_process.pl
r32125 r32507 8 8 my $host = hostname(); 9 9 my $date = `date`; 10 print "\n\n";11 print "Starting script $0 on $host at $date\n\n";12 13 10 use DateTime; 14 11 my $mjd_start = DateTime->now->mjd; # MJD of starting script … … 29 26 my $missing_tools; 30 27 my $vptool = can_run('vptool') or (warn "Can't find vptool" and $missing_tools = 1); 31 my $regtool = can_run('regtool') or (warn "Can't find regtool" and $missing_tools = 1);32 28 my $psvideophot = can_run('psvideophot') or (warn "Can't find psvideophot" and $missing_tools = 1); 33 29 my $listvideocells = can_run('listvideocells.pl') or (warn "Can't find listvideocells.pl" and $missing_tools = 1); … … 36 32 exit($PS_EXIT_CONFIG_ERROR); 37 33 } 38 my ($vp_id, $exp_id, $camera, $outroot, $dbname, $verbose, $no_update, $no_op, $redirect); 34 my ($vp_id, $exp_tag, $camera, $outroot, $dest_id, $dbname, $verbose, $no_update, $no_op, $redirect); 35 36 my $dbserver = "ipp049"; 39 37 40 38 GetOptions( 41 39 'vp_id=s' => \$vp_id, 42 'exp_id=s' => \$exp_id,43 40 'camera=s' => \$camera, 44 41 'outroot=s' => \$outroot, 42 'dest_id=s' => \$dest_id, 45 43 'dbname|d=s' => \$dbname, 46 44 'verbose' => \$verbose, … … 52 50 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 53 51 pod2usage( 54 -msg => "Required options: --vp_id -- exp_id --outroot --camera",52 -msg => "Required options: --vp_id --outroot --camera", 55 53 -exitval => 3, 56 54 ) unless defined $vp_id 57 and defined $exp_id58 55 and defined $camera 59 56 and defined $outroot; … … 62 59 $no_update = 1 if $no_op; 63 60 64 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $vp_id, 'nochip', 'nocell',$PS_EXIT_CONFIG_ERROR ); # IPP configuration61 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $vp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 65 62 66 63 my $logDest = $ipprc->filename("LOG.EXP", $outroot); 67 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $vp_id, 'nochip', 'nocell', $PS_EXIT_SYS_ERROR ) if $redirect; 64 if ($redirect) { 65 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $vp_id, $PS_EXIT_SYS_ERROR ); 68 66 69 my $source_id = $ipprc->source_id($dbname, $PS_TABLE_ID_DIFF); 67 print "\n\n"; 68 print "Starting script $0 on $host at $date\n\n"; 69 } 70 70 71 # Get list of components for subtraction 71 $vptool .= " -dbname $dbname" if $dbname; 72 $vptool .= " -dbserver $dbserver" if $dbserver; 73 74 # Get list of chips with pending video cells 72 75 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 73 76 my $files; 74 77 { 75 # my $command = "$vptool -pendingimfile -vp_id $vp_id"; 76 # $command .= " -dbname $dbname" if defined $dbname; 77 my $command = "$regtool -processedimfile -video_cells -exp_id $exp_id"; 78 $command .= " -dbname $dbname" if defined $dbname; 78 my $command = "$vptool -pendingimfile -vp_id $vp_id"; 79 79 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 80 80 run(command => $command, verbose => $verbose); 81 81 unless ($success) { 82 82 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 83 &my_die("Unable to perform vptool -pendingimfile: $error_code", $vp_id, 'nochip', 'nocell',$error_code);83 &my_die("Unable to perform vptool -pendingimfile: $error_code", $vp_id, $error_code); 84 84 } 85 85 86 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 87 &my_die("Unable to parse metadata config doc", $vp_id, 'nochip', 'nocell', $PS_EXIT_PROG_ERROR); 88 $files = parse_md_list($metadata) or 89 &my_die("Unable to parse metadata list", $vp_id, 'nochip', 'nocell', $PS_EXIT_PROG_ERROR); 86 my $output = join "", @$stdout_buf; 87 if ($output) { 88 my $metadata = $mdcParser->parse($output) or 89 &my_die("Unable to parse metadata config doc", $vp_id, $PS_EXIT_PROG_ERROR); 90 $files = parse_md_list($metadata) or 91 &my_die("Unable to parse metadata list", $vp_id, $PS_EXIT_PROG_ERROR); 92 } 90 93 } 91 94 … … 95 98 96 99 my $resolved = $ipprc->file_resolve($uri); 97 &my_die("Unable to resolve $uri", $vp_id, $ class_id, 'nocell', $PS_EXIT_UNKNOWN_ERROR) unless $resolved;100 &my_die("Unable to resolve $uri", $vp_id, $PS_EXIT_UNKNOWN_ERROR) unless $resolved; 98 101 99 102 my $command = "$listvideocells --file $resolved"; … … 102 105 unless ($success) { 103 106 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 104 &my_die("Unable to perform $command: $error_code", $vp_id, $class_id, 105 'nocell', $error_code); 107 &my_die("Unable to perform $command: $error_code", $vp_id, $error_code); 106 108 } 107 109 108 110 my @video_cells = split "\n", (join "", @$stdout_buf); 109 &my_die("No video cells found in $uri", $vp_id, $class_id, 110 'nocell', $PS_EXIT_UNKNOWN_ERROR) unless scalar @video_cells; 111 &my_die("No video cells found in $uri", $vp_id, $PS_EXIT_UNKNOWN_ERROR) unless scalar @video_cells; 111 112 112 113 foreach my $cell_id (@video_cells) { 113 my $command = "$psvideophot $outroot"; 114 my $path_base = "$outroot.$class_id.$cell_id"; 115 my $command = "$psvideophot $path_base"; 114 116 $command .= " -file $uri"; 115 117 $command .= " -cell_id $cell_id"; 116 $command .= " -dbname $dbname" if defined $dbname;118 my $vpstart = DateTime->now->mjd; 117 119 unless ($no_op) { 118 120 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 120 122 unless ($success) { 121 123 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 122 &my_die("Unable to perform ppSub: $error_code", $vp_id, $ class_id, $cell_id, $error_code);124 &my_die("Unable to perform ppSub: $error_code", $vp_id, $error_code); 123 125 } 124 126 … … 128 130 } 129 131 unless ($no_update) { 130 my $command = "$vptool -add vpcell -vp_id $vp_id -class_id $class_id -cell_id $cell_id";131 $command .= " -path_base $ outroot";132 133 $command .= " -d bname $dbname" if defined $dbname;132 my $command = "$vptool -addprocessedcell -vp_id $vp_id -class_id $class_id -cell_id $cell_id"; 133 $command .= " -path_base $path_base"; 134 $command .= " -hostname $host"; 135 $command .= " -dtime_photom " . ((DateTime->now->mjd - $vpstart) * 86400); 134 136 135 137 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 138 140 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 139 141 my $err_message = "Unable to perform vptool -addvpcell"; 140 &my_die("$err_message: $error_code", $vp_id, $ class_id, $cell_id, $error_code);142 &my_die("$err_message: $error_code", $vp_id, $error_code); 141 143 } 142 144 } 145 } 146 } 147 # TODO: if dest_id build results fileset and post it in the given destination on the data store 148 149 unless ($no_update) { 150 my $command = "$vptool -updaterun -vp_id $vp_id -set_state full"; 151 $command .= " -set_outroot $outroot"; 152 $command .= " -set_hostname $host"; 153 $command .= " -set_dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400); 154 155 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 156 run(command => $command, verbose => $verbose); 157 unless ($success) { 158 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 159 my $err_message = "Unable to perform vptool -updaterun"; 160 &my_die("$err_message: $error_code", $vp_id, $error_code); 143 161 } 144 162 } … … 149 167 { 150 168 my $msg = shift; # Warning message on die 151 my $vp_id = shift; 152 my $class_id = shift; # chip identifier 153 my $cell_id = shift; # chip identifier 169 my $vp_id = shift; # vpRun id 154 170 my $exit_code = shift; # Exit code to add 155 171 … … 157 173 158 174 warn($msg); 159 if (defined $vp_id and defined $class_id and not $no_update) { 160 my $command = "$vptool -vp_id $vp_id -class_id $class_id -cell_id -fault $exit_code"; 161 $command .= " -addvpcell"; 162 $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400)); 163 $command .= " -hostname $host" if defined $host; 164 $command .= " -path_base $outroot" if defined $outroot; 165 $command .= " -dbname $dbname" if defined $dbname; 175 if (defined $vp_id and not $no_update) { 176 my $command = "$vptool -vp_id $vp_id"; 177 $command .= " -updaterun"; 178 $command .= " -set_fault $exit_code"; 179 $command .= " -set_hostname $host" if defined $host; 180 $command .= " -set_outroot $outroot" if defined $outroot; 181 $command .= " -set_dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400); 182 166 183 run(command => $command, verbose => $verbose); 167 184 } … … 169 186 } 170 187 171 END {172 my $exit = $?;173 system("sync") == 0 or die "failed to execute sync: $!";174 $? = $exit;175 }176 177 188 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
