Changeset 32556 for trunk/ippScripts
- Timestamp:
- Oct 14, 2011, 4:41:16 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/videophot_process.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/videophot_process.pl
r32546 r32556 22 22 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 23 23 use Pod::Usage qw( pod2usage ); 24 use File::Temp qw( tempfile ); 25 use File::Basename qw( basename ); 24 26 25 27 # Look for programs we need … … 27 29 my $vptool = can_run('vptool') or (warn "Can't find vptool" and $missing_tools = 1); 28 30 my $psvideophot = can_run('psvideophot') or (warn "Can't find psvideophot" and $missing_tools = 1); 31 my $dumpvideo = can_run('dumpvideo') or (warn "Can't find dumpvideo" and $missing_tools = 1); 29 32 my $listvideocells = can_run('listvideocells.pl') or (warn "Can't find listvideocells.pl" and $missing_tools = 1); 33 my $dsreg = can_run('dsreg') or (warn "Can't find dsreg" and $missing_tools = 1); 30 34 if ($missing_tools) { 31 35 warn("Can't find required tools."); 32 36 exit($PS_EXIT_CONFIG_ERROR); 33 37 } 34 my ($vp_id, $camera, $outroot, $dest_id, $dbname, $verbose, $no_update, $no_op, $redirect); 38 my ($vp_id, $camera, $outroot, $dest_id, $dbname, $verbose, $no_update, $no_op, $redirect, $save_temps); 39 my ($product, $ds_dbname, $ds_dbhost); 35 40 36 41 GetOptions( … … 39 44 'outroot=s' => \$outroot, 40 45 'dest_id=s' => \$dest_id, 46 'product=s' => \$product, 47 'ds_dbname=s' => \$ds_dbname, 48 'ds_dbhost=s' => \$ds_dbhost, 41 49 'dbname|d=s' => \$dbname, 42 50 'verbose' => \$verbose, 51 'save-temps' => \$save_temps, 43 52 'no-update' => \$no_update, # Don't update the database? 44 53 'no-op' => \$no_op, # Don't do any operations? … … 54 63 and defined $outroot; 55 64 65 pod2usage( 66 -msg => " --product -ds_dbname and --dsdbhost are required if --dest_id", 67 -exitval => 3, 68 ) if ($dest_id and !( defined $product and defined $ds_dbname and defined $ds_dbhost)); 69 56 70 57 71 $no_update = 1 if $no_op; 72 $vptool .= " -dbname $dbname" if $dbname; 58 73 59 74 my $ipprc = PS::IPP::Config->new($camera) or my_die( "Unable to set up", $vp_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration … … 66 81 print "Starting script $0 on $host at $date\n\n"; 67 82 } 68 69 $vptool .= " -dbname $dbname" if $dbname;70 83 71 84 # Get list of chips with pending video cells … … 90 103 } 91 104 105 92 106 foreach my $file (@$files) { 93 107 my $class_id = $file->{class_id}; … … 110 124 foreach my $cell_id (@video_cells) { 111 125 my $path_base = "$outroot.$class_id.$cell_id"; 112 my $command = "$psvideophot $path_base"; 126 my $output = $ipprc->filename("PSVIDEOPHOT.OUTPUT", $path_base); 127 my $command = "$psvideophot $output"; 113 128 $command .= " -file $uri"; 129 $command .= " -class_id $class_id"; 114 130 $command .= " -cell_id $cell_id"; 115 131 my $vpstart = DateTime->now->mjd; … … 119 135 unless ($success) { 120 136 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 121 &my_die("Unable to perform p pSub: $error_code", $vp_id, $error_code);137 &my_die("Unable to perform psvideophot: $error_code", $vp_id, $error_code); 122 138 } 123 124 # check_output($outputStats, 1);125 139 } else { 126 140 print "Not executing: $command\n"; 127 141 } 142 # dump the video cell and the video table to a file 143 unless ($no_op) { 144 my $output = $path_base . ".fits"; 145 my $extname = "$cell_id"; 146 my $command = "$dumpvideo $uri $extname $output -includetable"; 147 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 148 run(command => $command, verbose => $verbose); 149 unless ($success) { 150 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 151 &my_die("Unable to perform dumpvideo: $error_code", $vp_id, $error_code); 152 } 153 } else { 154 print "Not executing: $command\n"; 155 } 156 128 157 unless ($no_update) { 129 158 my $command = "$vptool -addprocessedcell -vp_id $vp_id -class_id $class_id -cell_id $cell_id"; … … 142 171 } 143 172 } 144 # TODO: if dest_id build results fileset and post it in the given destination on the data store 173 if ($dest_id) { 174 my $command = "$vptool -processedcell -vp_id $vp_id"; 175 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 176 run(command => $command, verbose => $verbose); 177 unless ($success) { 178 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 179 &my_die("Unable to perform vptool -pendingimfile: $error_code", $vp_id, $error_code); 180 } 181 182 my $output = join "", @$stdout_buf; 183 my $cells; 184 if ($output) { 185 my $metadata = $mdcParser->parse($output) or 186 &my_die("Unable to parse metadata config doc", $vp_id, $PS_EXIT_PROG_ERROR); 187 $cells = parse_md_list($metadata) or 188 &my_die("Unable to parse metadata list", $vp_id, $PS_EXIT_PROG_ERROR); 189 } 190 my ($reglist, $reglistName) = tempfile("/tmp/filelist.$vp_id.XXXX", UNLINK => !$save_temps); 191 192 if ($redirect) { 193 print $reglist "$logDest|||text|\n"; 194 } 195 my @exts = qw( vpt fits ); 196 my @types = qw( table fits ); 197 foreach my $cell (@$cells) { 198 my $path_base = $cell->{path_base}; 199 for (my $i = 0; $i < scalar @exts; $i++) { 200 my $file = "$path_base.$exts[$i]"; 201 my $type = $types[$i]; 202 203 print $reglist "$file|||$type|\n"; 204 } 205 206 } 207 close $reglist or &my_die("failed to close $reglistName", $vp_id, $PS_EXIT_UNKNOWN_ERROR); 208 unless ($no_update or $no_op) { 209 my $fileset = basename($outroot); 210 my $command = "$dsreg --add $fileset --product $product --type dump --list $reglistName"; 211 $command .= " --abspath --link"; 212 $command .= " --dbname $ds_dbname --dbhost $ds_dbhost"; 213 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 214 run(command => $command, verbose => $verbose); 215 unless ($success) { 216 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 217 &my_die("Unable to perform $command error_code: $error_code", $vp_id, $error_code); 218 } 219 } 220 } 145 221 146 222 unless ($no_update) {
Note:
See TracChangeset
for help on using the changeset viewer.
