Changeset 28003 for branches/pap/pstamp/scripts/pstamp_parser_run.pl
- Timestamp:
- May 18, 2010, 12:49:05 PM (16 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pstamp/scripts/pstamp_parser_run.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/pstamp/scripts/pstamp_parser_run.pl
r26151 r28003 28 28 my $redirect_output; 29 29 my $product; 30 my $outdir; 31 my $label; 30 32 my $verbose; 31 33 my $dbname; … … 36 38 'uri=s' => \$uri, 37 39 'product=s' => \$product, 40 'outdir=s' => \$outdir, 41 'label=s' => \$label, 38 42 'redirect-output' => \$redirect_output, 39 43 'verbose' => \$verbose, … … 79 83 } 80 84 81 # workdir is where all of the files generated for this request are placed 82 # NOTE: this location needs to be kept in sync with the web interface ( request.php ) 83 my $datestr = strftime "%Y%m%d", gmtime; 84 my $datedir = "$pstamp_workdir/$datestr"; 85 if (! -e $datedir ) { 86 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 85 if (!$outdir or ($outdir eq "NULL")) { 86 # outdir is where all of the files generated for this request are placed 87 # NOTE: this location needs to be kept in sync with the web interface ( request.php ) 88 my $datestr = strftime "%Y%m%d", gmtime; 89 my $datedir = "$pstamp_workdir/$datestr"; 90 if (! -e $datedir ) { 91 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 92 $PS_EXIT_CONFIG_ERROR); 93 } 94 95 $outdir = "$datedir/$req_id"; 96 } 97 98 if (! -e $outdir ) { 99 mkdir $outdir or my_die("failed to create working directory $outdir for request id $req_id", $req_id, 87 100 $PS_EXIT_CONFIG_ERROR); 88 101 } 89 90 my $workdir = "$datedir/$req_id"; 91 if (! -e $workdir ) { 92 mkdir $workdir or my_die("failed to create working directory $workdir for request id $req_id", $req_id, 93 $PS_EXIT_CONFIG_ERROR); 94 } 102 95 103 96 104 if ($redirect_output) { 97 my $logDest = "$ workdir/psparse.$req_id.log";105 my $logDest = "$outdir/psparse.$req_id.log"; 98 106 $ipprc->redirect_output($logDest); 99 107 } … … 106 114 107 115 my $fn = basename($uri); 108 my $new_uri = "$ workdir/$fn";116 my $new_uri = "$outdir/$fn"; 109 117 if ($uri =~ /^http:/) { 110 118 # if the uri is an http uri download the file … … 116 124 } 117 125 } elsif ($uri ne $new_uri) { 118 # put a link to the file into the workdir126 # copy the request file into outdir 119 127 if (-e $new_uri) { 128 # file exists already delete it incase the previous copy is bogus 120 129 unlink $new_uri or my_die("failed to unlink $new_uri", $req_id, $PS_EXIT_UNKNOWN_ERROR); 121 130 } 122 131 if (! copy $uri, $new_uri) { 123 my_die ("failed to copy request file $uri to workdir $ workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR);132 my_die ("failed to copy request file $uri to workdir $outdir", $req_id, $PS_EXIT_UNKNOWN_ERROR); 124 133 } 125 134 } … … 146 155 if ($request_type eq "PS1_PS_REQUEST") { 147 156 $reqType = 'pstamp'; 148 $parse_cmd = $pstampparse; 157 $parse_cmd = "$pstampparse"; 158 $parse_cmd .= " --label $label" if $label; 149 159 } elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") { 150 160 $reqType = 'dquery'; 151 $parse_cmd = $dqueryparse; 161 $parse_cmd = "$dqueryparse"; 162 $parse_cmd .= " --label $label" if $label; 152 163 } else { 153 164 print STDERR "Unknown request type $request_type found in $uri"; … … 169 180 # that they sent us a request file that we don't understand 170 181 171 my $command = "$pstamptool -updatereq -req_id $req_id -s tate run";172 $command .= " - reqType unknown";173 $command .= " - fault $PS_EXIT_DATA_ERROR";182 my $command = "$pstamptool -updatereq -req_id $req_id -set_state run"; 183 $command .= " -set_reqType unknown"; 184 $command .= " -set_fault $PS_EXIT_DATA_ERROR"; 174 185 $command .= " -dbname $dbname" if $dbname; 175 186 $command .= " -dbserver $dbserver" if $dbserver; … … 182 193 } 183 194 184 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --out _dir $workdir --file $uri";195 $parse_cmd .= " --mode queue_job --req_id $req_id --product $product --outdir $outdir --file $uri"; 185 196 $parse_cmd .= " --dbname $dbname" if $dbname; 186 197 $parse_cmd .= " --dbserver $dbserver" if $dbserver; … … 190 201 my $fault; 191 202 { 192 my $error_file_name = "$ workdir/parse_error.txt";203 my $error_file_name = "$outdir/parse_error.txt"; 193 204 # get rid of any error file from previous attempt to parse this request 194 205 unlink $error_file_name if (-e $error_file_name); … … 215 226 unless ($success) { 216 227 $fault = $error_code >> 8; 217 $newState = "stop";228 # $newState = "stop"; 218 229 } 219 230 } … … 223 234 # 224 235 { 225 my $command = "$pstamptool -updatereq -req_id $req_id -state $newState"; 226 $command .= " -reqType $reqType" if $reqType; 227 $command .= " -uri $new_uri" if $new_uri; 228 $command .= " -fault $fault" if $fault; 236 my $command = "$pstamptool -updatereq -req_id $req_id -set_state $newState"; 237 $command .= " -set_outdir $outdir"; 238 $command .= " -set_reqType $reqType" if $reqType; 239 $command .= " -set_uri $new_uri" if $new_uri; 240 $command .= " -set_fault $fault" if $fault; 229 241 $command .= " -dbname $dbname" if $dbname; 230 242 $command .= " -dbserver $dbserver" if $dbserver; … … 265 277 carp($msg); 266 278 267 my $command = "$pstamptool -updatereq -req_id $req_id - fault $fault";279 my $command = "$pstamptool -updatereq -req_id $req_id -set_fault $fault"; 268 280 $command .= " -dbname $dbname" if $dbname; 269 281 $command .= " -dbserver $dbserver" if $dbserver;
Note:
See TracChangeset
for help on using the changeset viewer.
