Changeset 17893 for trunk/pstamp/scripts/pstamp_parser_run.pl
- Timestamp:
- Jun 3, 2008, 9:37:51 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_parser_run.pl (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_parser_run.pl
r16975 r17893 5 5 ### 6 6 7 #XXX TODO: accept dbname save-temps and verbose as command line parameters 8 #XXX see notes about error handling 9 7 10 use warnings; 8 11 use strict; 9 12 10 13 use Sys::Hostname; 11 my $host = hostname(); 12 print "\n\n"; 13 print "Starting script $0 on $host\n\n"; 14 15 my $verbose = 1; 16 if ($verbose) { 17 my $host = hostname(); 18 print "\n\n"; 19 print "Starting script $0 on $host\n\n"; 20 } 14 21 15 22 if (@ARGV != 1) { … … 18 25 19 26 my $request_id = $ARGV[0]; 20 21 27 22 28 use IPC::Cmd 0.36 qw( can_run run ); … … 57 63 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 58 64 my $pstampparse = can_run('pstampparse') or (warn "Can't find pstampparse" and $missing_tools = 1); 65 my $dqueryparse = can_run('dqueryparse.pl') or (warn "Can't find dqueryparse.pl" and $missing_tools = 1); 59 66 my $dsget = can_run('dsget') or (warn "Can't find dsget" and $missing_tools = 1); 60 67 … … 71 78 my $command = "$pstamptool -pendingreq -req_id $request_id"; 72 79 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 73 run(command => $command, verbose => 1);80 run(command => $command, verbose => $verbose); 74 81 unless ($success) { 75 82 die("Unable to perform $command error code: $error_code"); … … 85 92 my $requests = parse_md_list($metadata); 86 93 87 $psrequest = ${@$requests}[0]; 94 # TODO: We are assuming that we get an array of length 1 (or zero) 95 # should we fail if we get more? 96 #$psrequest = ${@$requests}[0]; 97 $psrequest = $requests->[0]; 88 98 } 89 99 … … 112 122 my $command = "$dsget --uri $uri --filename $new_uri"; 113 123 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 114 run(command => $command, verbose => 1);124 run(command => $command, verbose => $verbose); 115 125 unless ($success) { 116 126 die("Unable to perform $command error code: $error_code"); … … 121 131 } 122 132 123 # create the output diredtory133 # find the name of the output directory 124 134 my $outdir; 125 135 if ($ds_id) { 126 136 my $command = "$pstamptool -datastore -ds_id $ds_id"; 127 137 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 128 run(command => $command, verbose => 1);138 run(command => $command, verbose => $verbose); 129 139 unless ($success) { 130 140 die("Unable to perform $command error code: $error_code"); … … 140 150 my $dataStores = parse_md_list($metadata); 141 151 142 my $dataStore = $ {@$dataStores}[0];152 my $dataStore = $dataStores->[0]; 143 153 144 154 $outdir = "$outputDataStoreRoot/$psrequest->{outFileset}"; … … 147 157 } 148 158 159 # create the output directory 149 160 if (! -e $outdir ) { 150 161 mkdir $outdir or die("unable to create output directory $outdir"); … … 153 164 } 154 165 155 # run pstampparse to parse the queue the jobs for this request 166 # run the appropriate parse command to parse the queue the jobs for this request 167 # first check the extension header to find the EXTNAME 168 my $request_type = find_request_type($uri); 169 170 print STDERR "request_type is $request_type\n" if $verbose; 171 172 my $parse_cmd; 173 if ($request_type eq "PS1_PS_REQUEST") { 174 $parse_cmd = $pstampparse . " -mode queue_job -req_id $request_id -out_dir $outdir $uri"; 175 } elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") { 176 $parse_cmd = $dqueryparse . " --mode queue_job --req_id $request_id --out_dir $outdir --uri $uri"; 177 } 178 179 if (!$parse_cmd) { 180 # XXX TODO mark the error state for the job and set it to stop 181 die "null request type found in $uri" if !$request_type; 182 die "unknown request type $request_type found in $uri"; 183 } 184 156 185 { 157 my $command = "$pstampparse -mode queue_job -req_id $request_id -out_dir $outdir $uri"; 158 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 159 run(command => $command, verbose => 1); 160 unless ($success) { 161 # die("Unable to perform $command error code: $error_code"); 186 my $command = "$parse_cmd"; 187 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 188 run(command => $command, verbose => $verbose); 189 unless ($success) { 162 190 if (!open OUT, ">$outdir/parse_error") { 163 191 die("unable to open parse_error file $outdir/parse_error"); … … 167 195 } 168 196 } 169 170 197 # XXX make sure that a job got actually got queued. If not set the request result and set state to 171 198 # run so that the "request finisher" can build the results file. … … 177 204 my $command = "$pstamptool -processedreq -req_id $request_id -state run"; 178 205 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 179 run(command => $command, verbose => 1);206 run(command => $command, verbose => $verbose); 180 207 unless ($success) { 181 208 die("Unable to perform $command error code: $error_code"); … … 184 211 185 212 exit 0; 213 214 sub find_request_type { 215 # find the EXTNAME in the input fits table 216 # TODO: do this right handling errors etc. 217 my $file_name = shift; 218 my $out = `echo $file_name | fields -x 0 EXTNAME`; 219 220 # output from fields is filename value 221 my ($dummy, $extname) = split " ", $out; 222 223 return $extname; 224 }
Note:
See TracChangeset
for help on using the changeset viewer.
